Skip to content

Commit

Permalink
Merge pull request #2964 from ocallesp/localize-variable
Browse files Browse the repository at this point in the history
Localize Variable Explorer in vscode insiders
  • Loading branch information
ocallesp authored May 4, 2023
2 parents 3fc4a4f + 6a5fe6f commit bad8771
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
5 changes: 5 additions & 0 deletions eng/Localize/LocProject.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
17 changes: 11 additions & 6 deletions src/polyglot-notebooks-vscode-common/src/variableExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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) {
Expand Down
8 changes: 8 additions & 0 deletions src/polyglot-notebooks-vscode-insiders/l10n/bundle.l10n.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"VariableGridColumnActions": "Actions",
"VariableGridColumnName": "Name",
"VariableGridColumnValue": "Value",
"VariableGridColumnType": "Type",
"VariableGridColumnKernel": "Kernel",
"VariableGridshareTemplate": "Share value {value-name} from {kernel-name} kernel"
}
3 changes: 2 additions & 1 deletion src/polyglot-notebooks-vscode-insiders/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
},
"virtualWorkspaces": true
},
"l10n": "./l10n",
"contributes": {
"notebooks": [
{
Expand Down Expand Up @@ -842,4 +843,4 @@
"vscode-uri": "3.0.6",
"@vscode/l10n": "^0.0.10"
}
}
}

0 comments on commit bad8771

Please sign in to comment.