From 703a6103616e8219d176de857f7d469cf5270b7c Mon Sep 17 00:00:00 2001 From: Oliver Schwendener Date: Mon, 29 Apr 2019 22:57:13 +0200 Subject: [PATCH] Use translations in commandline plugin --- src/common/translation/english-translation-set.ts | 2 ++ src/common/translation/german-translation-set.ts | 2 ++ src/common/translation/translation-set.ts | 2 ++ src/main/plugins/commandline-plugin/commandline-plugin.ts | 7 +++++-- src/main/production/production-search-engine.ts | 2 +- 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/common/translation/english-translation-set.ts b/src/common/translation/english-translation-set.ts index d9498e448..b547fd1d1 100644 --- a/src/common/translation/english-translation-set.ts +++ b/src/common/translation/english-translation-set.ts @@ -31,6 +31,8 @@ export const englishTranslationSet: TranslationSet = { successfullyClearedCachesBeforeExit: "Successfully cleared caches before exit", successfullyClearedExecutionLog: "Successfully cleared execution log", + commandlineSearchResultDescription: "Execute {{command}}", + // settings generalSettingsMenuSection: "General", pluginSettingsMenuSection: "Plugins", diff --git a/src/common/translation/german-translation-set.ts b/src/common/translation/german-translation-set.ts index dff2f0801..887f2e730 100644 --- a/src/common/translation/german-translation-set.ts +++ b/src/common/translation/german-translation-set.ts @@ -31,6 +31,8 @@ export const germanTranslationSet: TranslationSet = { successfullyClearedCachesBeforeExit: "Erfolgreich alle Zwischenspeicher vor dem Beenden gelöscht", successfullyClearedExecutionLog: "Erfolgreich den Ausführungslog gelöscht", + commandlineSearchResultDescription: "{{command}} ausführen", + // settings generalSettingsMenuSection: "Allgemein", pluginSettingsMenuSection: "Plugins", diff --git a/src/common/translation/translation-set.ts b/src/common/translation/translation-set.ts index 37d243857..3d1c897de 100644 --- a/src/common/translation/translation-set.ts +++ b/src/common/translation/translation-set.ts @@ -28,6 +28,8 @@ export interface TranslationSet { successfullyClearedCachesBeforeExit: string; successfullyClearedExecutionLog: string; + commandlineSearchResultDescription: string; + // Settings generalSettingsMenuSection: string; pluginSettingsMenuSection: string; diff --git a/src/main/plugins/commandline-plugin/commandline-plugin.ts b/src/main/plugins/commandline-plugin/commandline-plugin.ts index 8cd09f884..1021e4736 100644 --- a/src/main/plugins/commandline-plugin/commandline-plugin.ts +++ b/src/main/plugins/commandline-plugin/commandline-plugin.ts @@ -13,9 +13,11 @@ export class CommandlinePlugin implements ExecutionPlugin { public readonly autoCompletionSupported = false; private readonly commandlineExecutor: (command: string) => Promise; private config: CommandlineOptions; + private translationSet: TranslationSet; - constructor(config: CommandlineOptions, commandlineExecutor: (command: string) => Promise) { + constructor(config: CommandlineOptions, translationSet: TranslationSet, commandlineExecutor: (command: string) => Promise) { this.config = config; + this.translationSet = translationSet; this.commandlineExecutor = commandlineExecutor; } @@ -28,7 +30,7 @@ export class CommandlinePlugin implements ExecutionPlugin { return new Promise((resolve, reject) => { const command = userInput.replace(">", "").trim(); const result: SearchResultItem = { - description: `Execute ${command} in Terminal`, + description: this.translationSet.commandlineSearchResultDescription.replace("{{command}}", command), executionArgument: command, hideMainWindowAfterExecution: true, icon: defaultTerminalIcon, @@ -60,6 +62,7 @@ export class CommandlinePlugin implements ExecutionPlugin { public updateConfig(updatedConfig: UserConfigOptions, translationSet: TranslationSet): Promise { return new Promise((resolve) => { this.config = updatedConfig.commandlineOptions; + this.translationSet = translationSet; resolve(); }); } diff --git a/src/main/production/production-search-engine.ts b/src/main/production/production-search-engine.ts index 88ee31e4c..8880343be 100644 --- a/src/main/production/production-search-engine.ts +++ b/src/main/production/production-search-engine.ts @@ -86,7 +86,7 @@ export const getProductionSearchEngine = (config: UserConfigOptions, translation new UrlPlugin(config.urlOptions, translationSet, urlExecutor), new EmailPlugin(config.emailOptions, translationSet, urlExecutor), new CurrencyConverterPlugin(config.currencyConverterOptions, translationSet, electronClipboardCopier), - new CommandlinePlugin(config.commandlineOptions, commandlineExecutor), + new CommandlinePlugin(config.commandlineOptions, translationSet, commandlineExecutor), ]; const fallbackPlugins: ExecutionPlugin[] = [