From 6a5fe6f977a7a1b664818de844d0247e018f0376 Mon Sep 17 00:00:00 2001 From: Osvaldo Calles Date: Wed, 3 May 2023 23:48:44 -0700 Subject: [PATCH] Localize Variable Explorer in vscode insiders --- eng/Localize/LocProject.json | 5 +++++ .../src/variableExplorer.ts | 17 +++++++++++------ .../l10n/bundle.l10n.json | 8 ++++++++ .../package.json | 3 ++- 4 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 src/polyglot-notebooks-vscode-insiders/l10n/bundle.l10n.json diff --git a/eng/Localize/LocProject.json b/eng/Localize/LocProject.json index aad9d93c7c..7a974fd7d3 100644 --- a/eng/Localize/LocProject.json +++ b/eng/Localize/LocProject.json @@ -54,6 +54,11 @@ "SourceFile": "src\\polyglot-notebooks-vscode-insiders\\package.nls.json", "OutputPath": "src\\polyglot-notebooks-vscode-insiders", "CopyOption": "LangIDOnName" + }, + { + "SourceFile": "src\\polyglot-notebooks-vscode-insiders\\l10n\\bundle.l10n.json", + "OutputPath": "src\\polyglot-notebooks-vscode-insiders\\l10n", + "CopyOption": "LangIDOnName" } ], "LanguageSet": "VS_Main_Languages" diff --git a/src/polyglot-notebooks-vscode-common/src/variableExplorer.ts b/src/polyglot-notebooks-vscode-common/src/variableExplorer.ts index 13a365a91b..758166bdaa 100644 --- a/src/polyglot-notebooks-vscode-common/src/variableExplorer.ts +++ b/src/polyglot-notebooks-vscode-common/src/variableExplorer.ts @@ -152,12 +152,12 @@ class WatchWindowTableViewProvider implements vscode.WebviewViewProvider { if (this.webview) { const localizationStrings: GridLocalization = { - actionsColumnHeader: 'Actions', - nameColumnHeader: 'Name', - valueColumnHeader: 'Value', - typeColumnHeader: 'Type', - kernelNameColumnHeader: 'Kernel', - shareTemplate: 'Share value {value-name} from {kernel-name} kernel' + actionsColumnHeader: this.translate('VariableGridColumnActions', 'Actions'), + nameColumnHeader: this.translate('VariableGridColumnName', 'Name'), + valueColumnHeader: this.translate('VariableGridColumnValue', 'Value'), + typeColumnHeader: this.translate('VariableGridColumnType', 'Type'), + kernelNameColumnHeader: this.translate('VariableGridColumnKernel', 'Kernel'), + shareTemplate: this.translate('VariableGridshareTemplate', 'Share value {value-name} from {kernel-name} kernel') }; this.webview.postMessage({ @@ -168,6 +168,11 @@ class WatchWindowTableViewProvider implements vscode.WebviewViewProvider { } } + private translate(key: string, fallback: string): string { + const translation = vscode.l10n.t(key); + return translation === key ? fallback : translation; + } + showNotebookVariables(notebookUri: vscodeLike.Uri | undefined) { let rows: VariableGridRow[] = []; if (notebookUri) { diff --git a/src/polyglot-notebooks-vscode-insiders/l10n/bundle.l10n.json b/src/polyglot-notebooks-vscode-insiders/l10n/bundle.l10n.json new file mode 100644 index 0000000000..22c5473cd0 --- /dev/null +++ b/src/polyglot-notebooks-vscode-insiders/l10n/bundle.l10n.json @@ -0,0 +1,8 @@ +{ + "VariableGridColumnActions": "Actions", + "VariableGridColumnName": "Name", + "VariableGridColumnValue": "Value", + "VariableGridColumnType": "Type", + "VariableGridColumnKernel": "Kernel", + "VariableGridshareTemplate": "Share value {value-name} from {kernel-name} kernel" +} \ No newline at end of file diff --git a/src/polyglot-notebooks-vscode-insiders/package.json b/src/polyglot-notebooks-vscode-insiders/package.json index 8de61559c0..0202edb9d1 100644 --- a/src/polyglot-notebooks-vscode-insiders/package.json +++ b/src/polyglot-notebooks-vscode-insiders/package.json @@ -65,6 +65,7 @@ }, "virtualWorkspaces": true }, + "l10n": "./l10n", "contributes": { "notebooks": [ { @@ -842,4 +843,4 @@ "vscode-uri": "3.0.6", "@vscode/l10n": "^0.0.10" } -} +} \ No newline at end of file