Skip to content
This repository has been archived by the owner on Dec 31, 2024. It is now read-only.

Commit

Permalink
Use translations in commandline plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverschwendener committed Apr 29, 2019
1 parent 7b6bc0f commit 703a610
Showing 5 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/common/translation/english-translation-set.ts
Original file line number Diff line number Diff line change
@@ -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",
2 changes: 2 additions & 0 deletions src/common/translation/german-translation-set.ts
Original file line number Diff line number Diff line change
@@ -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",
2 changes: 2 additions & 0 deletions src/common/translation/translation-set.ts
Original file line number Diff line number Diff line change
@@ -28,6 +28,8 @@ export interface TranslationSet {
successfullyClearedCachesBeforeExit: string;
successfullyClearedExecutionLog: string;

commandlineSearchResultDescription: string;

// Settings
generalSettingsMenuSection: string;
pluginSettingsMenuSection: string;
7 changes: 5 additions & 2 deletions src/main/plugins/commandline-plugin/commandline-plugin.ts
Original file line number Diff line number Diff line change
@@ -13,9 +13,11 @@ export class CommandlinePlugin implements ExecutionPlugin {
public readonly autoCompletionSupported = false;
private readonly commandlineExecutor: (command: string) => Promise<void>;
private config: CommandlineOptions;
private translationSet: TranslationSet;

constructor(config: CommandlineOptions, commandlineExecutor: (command: string) => Promise<void>) {
constructor(config: CommandlineOptions, translationSet: TranslationSet, commandlineExecutor: (command: string) => Promise<void>) {
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<void> {
return new Promise((resolve) => {
this.config = updatedConfig.commandlineOptions;
this.translationSet = translationSet;
resolve();
});
}
2 changes: 1 addition & 1 deletion src/main/production/production-search-engine.ts
Original file line number Diff line number Diff line change
@@ -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[] = [

0 comments on commit 703a610

Please sign in to comment.