Skip to content

Commit 2d82025

Browse files
authored
Adopt l10n for configuration-editing (microsoft#165521)
For microsoft#164438
1 parent ed0fd3c commit 2d82025

File tree

5 files changed

+51
-63
lines changed

5 files changed

+51
-63
lines changed

extensions/configuration-editing/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
"watch": "gulp watch-extension:configuration-editing"
2121
},
2222
"dependencies": {
23-
"jsonc-parser": "^2.2.1",
24-
"vscode-nls": "^5.2.0"
23+
"jsonc-parser": "^2.2.1"
2524
},
2625
"capabilities": {
2726
"virtualWorkspaces": true,

extensions/configuration-editing/src/configurationEditingMain.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55

66
import { getLocation, JSONPath, parse, visit, Location } from 'jsonc-parser';
77
import * as vscode from 'vscode';
8-
import * as nls from 'vscode-nls';
98
import { SettingsDocument } from './settingsDocumentHelper';
109
import { provideInstalledExtensionProposals } from './extensionsProposals';
11-
const localize = nls.loadMessageBundle();
1210

1311
export function activate(context: vscode.ExtensionContext): void {
1412
//settings.json suggestions
@@ -46,21 +44,21 @@ function registerVariableCompletions(pattern: string): vscode.Disposable {
4644
}
4745

4846
return [
49-
{ label: 'workspaceFolder', detail: localize('workspaceFolder', "The path of the folder opened in VS Code") },
50-
{ label: 'workspaceFolderBasename', detail: localize('workspaceFolderBasename', "The name of the folder opened in VS Code without any slashes (/)") },
51-
{ label: 'relativeFile', detail: localize('relativeFile', "The current opened file relative to ${workspaceFolder}") },
52-
{ label: 'relativeFileDirname', detail: localize('relativeFileDirname', "The current opened file's dirname relative to ${workspaceFolder}") },
53-
{ label: 'file', detail: localize('file', "The current opened file") },
54-
{ label: 'cwd', detail: localize('cwd', "The task runner's current working directory on startup") },
55-
{ label: 'lineNumber', detail: localize('lineNumber', "The current selected line number in the active file") },
56-
{ label: 'selectedText', detail: localize('selectedText', "The current selected text in the active file") },
57-
{ label: 'fileDirname', detail: localize('fileDirname', "The current opened file's dirname") },
58-
{ label: 'fileExtname', detail: localize('fileExtname', "The current opened file's extension") },
59-
{ label: 'fileBasename', detail: localize('fileBasename', "The current opened file's basename") },
60-
{ label: 'fileBasenameNoExtension', detail: localize('fileBasenameNoExtension', "The current opened file's basename with no file extension") },
61-
{ label: 'defaultBuildTask', detail: localize('defaultBuildTask', "The name of the default build task. If there is not a single default build task then a quick pick is shown to choose the build task.") },
62-
{ label: 'pathSeparator', detail: localize('pathSeparator', "The character used by the operating system to separate components in file paths") },
63-
{ label: 'extensionInstallFolder', detail: localize('extensionInstallFolder', "The path where an an extension is installed."), param: 'publisher.extension' },
47+
{ label: 'workspaceFolder', detail: vscode.l10n.t("The path of the folder opened in VS Code") },
48+
{ label: 'workspaceFolderBasename', detail: vscode.l10n.t("The name of the folder opened in VS Code without any slashes (/)") },
49+
{ label: 'relativeFile', detail: vscode.l10n.t("The current opened file relative to ${workspaceFolder}") },
50+
{ label: 'relativeFileDirname', detail: vscode.l10n.t("The current opened file's dirname relative to ${workspaceFolder}") },
51+
{ label: 'file', detail: vscode.l10n.t("The current opened file") },
52+
{ label: 'cwd', detail: vscode.l10n.t("The task runner's current working directory on startup") },
53+
{ label: 'lineNumber', detail: vscode.l10n.t("The current selected line number in the active file") },
54+
{ label: 'selectedText', detail: vscode.l10n.t("The current selected text in the active file") },
55+
{ label: 'fileDirname', detail: vscode.l10n.t("The current opened file's dirname") },
56+
{ label: 'fileExtname', detail: vscode.l10n.t("The current opened file's extension") },
57+
{ label: 'fileBasename', detail: vscode.l10n.t("The current opened file's basename") },
58+
{ label: 'fileBasenameNoExtension', detail: vscode.l10n.t("The current opened file's basename with no file extension") },
59+
{ label: 'defaultBuildTask', detail: vscode.l10n.t("The name of the default build task. If there is not a single default build task then a quick pick is shown to choose the build task.") },
60+
{ label: 'pathSeparator', detail: vscode.l10n.t("The character used by the operating system to separate components in file paths") },
61+
{ label: 'extensionInstallFolder', detail: vscode.l10n.t("The path where an an extension is installed."), param: 'publisher.extension' },
6462
].map(variable => ({
6563
label: `\${${variable.label}}`,
6664
range,

extensions/configuration-editing/src/extensionsProposals.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as vscode from 'vscode';
7-
import * as nls from 'vscode-nls';
8-
const localize = nls.loadMessageBundle();
97

108

119
export async function provideInstalledExtensionProposals(existing: string[], additionalText: string, range: vscode.Range, includeBuiltinExtensions: boolean): Promise<vscode.CompletionItem[] | vscode.CompletionList> {
@@ -23,7 +21,7 @@ export async function provideInstalledExtensionProposals(existing: string[], add
2321
return item;
2422
});
2523
} else {
26-
const example = new vscode.CompletionItem(localize('exampleExtension', "Example"));
24+
const example = new vscode.CompletionItem(vscode.l10n.t("Example"));
2725
example.insertText = '"vscode.csharp"';
2826
example.kind = vscode.CompletionItemKind.Value;
2927
example.range = range;
@@ -48,7 +46,7 @@ export async function provideWorkspaceTrustExtensionProposals(existing: string[]
4846
return item;
4947
});
5048
} else {
51-
const example = new vscode.CompletionItem(localize('exampleExtension', "Example"));
49+
const example = new vscode.CompletionItem(vscode.l10n.t("Example"));
5250
example.insertText = '"vscode.csharp: {\n\t"supported": false,\n\t"version": "0.0.0"\n}`;"';
5351
example.kind = vscode.CompletionItemKind.Value;
5452
example.range = range;

extensions/configuration-editing/src/settingsDocumentHelper.ts

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55

66
import * as vscode from 'vscode';
77
import { getLocation, Location, parse } from 'jsonc-parser';
8-
import * as nls from 'vscode-nls';
98
import { provideInstalledExtensionProposals } from './extensionsProposals';
109

11-
const localize = nls.loadMessageBundle();
1210
const OVERRIDE_IDENTIFIER_REGEX = /\[([^\[\]]*)\]/g;
1311

1412
export class SettingsDocument {
@@ -107,20 +105,20 @@ export class SettingsDocument {
107105
};
108106

109107

110-
completions.push(this.newSimpleCompletionItem(getText('activeEditorShort'), range, localize('activeEditorShort', "the file name (e.g. myFile.txt)")));
111-
completions.push(this.newSimpleCompletionItem(getText('activeEditorMedium'), range, localize('activeEditorMedium', "the path of the file relative to the workspace folder (e.g. myFolder/myFileFolder/myFile.txt)")));
112-
completions.push(this.newSimpleCompletionItem(getText('activeEditorLong'), range, localize('activeEditorLong', "the full path of the file (e.g. /Users/Development/myFolder/myFileFolder/myFile.txt)")));
113-
completions.push(this.newSimpleCompletionItem(getText('activeFolderShort'), range, localize('activeFolderShort', "the name of the folder the file is contained in (e.g. myFileFolder)")));
114-
completions.push(this.newSimpleCompletionItem(getText('activeFolderMedium'), range, localize('activeFolderMedium', "the path of the folder the file is contained in, relative to the workspace folder (e.g. myFolder/myFileFolder)")));
115-
completions.push(this.newSimpleCompletionItem(getText('activeFolderLong'), range, localize('activeFolderLong', "the full path of the folder the file is contained in (e.g. /Users/Development/myFolder/myFileFolder)")));
116-
completions.push(this.newSimpleCompletionItem(getText('rootName'), range, localize('rootName', "name of the workspace (e.g. myFolder or myWorkspace)")));
117-
completions.push(this.newSimpleCompletionItem(getText('rootPath'), range, localize('rootPath', "file path of the workspace (e.g. /Users/Development/myWorkspace)")));
118-
completions.push(this.newSimpleCompletionItem(getText('folderName'), range, localize('folderName', "name of the workspace folder the file is contained in (e.g. myFolder)")));
119-
completions.push(this.newSimpleCompletionItem(getText('folderPath'), range, localize('folderPath', "file path of the workspace folder the file is contained in (e.g. /Users/Development/myFolder)")));
120-
completions.push(this.newSimpleCompletionItem(getText('appName'), range, localize('appName', "e.g. VS Code")));
121-
completions.push(this.newSimpleCompletionItem(getText('remoteName'), range, localize('remoteName', "e.g. SSH")));
122-
completions.push(this.newSimpleCompletionItem(getText('dirty'), range, localize('dirty', "an indicator for when the active editor has unsaved changes")));
123-
completions.push(this.newSimpleCompletionItem(getText('separator'), range, localize('separator', "a conditional separator (' - ') that only shows when surrounded by variables with values")));
108+
completions.push(this.newSimpleCompletionItem(getText('activeEditorShort'), range, vscode.l10n.t("the file name (e.g. myFile.txt)")));
109+
completions.push(this.newSimpleCompletionItem(getText('activeEditorMedium'), range, vscode.l10n.t("the path of the file relative to the workspace folder (e.g. myFolder/myFileFolder/myFile.txt)")));
110+
completions.push(this.newSimpleCompletionItem(getText('activeEditorLong'), range, vscode.l10n.t("the full path of the file (e.g. /Users/Development/myFolder/myFileFolder/myFile.txt)")));
111+
completions.push(this.newSimpleCompletionItem(getText('activeFolderShort'), range, vscode.l10n.t("the name of the folder the file is contained in (e.g. myFileFolder)")));
112+
completions.push(this.newSimpleCompletionItem(getText('activeFolderMedium'), range, vscode.l10n.t("the path of the folder the file is contained in, relative to the workspace folder (e.g. myFolder/myFileFolder)")));
113+
completions.push(this.newSimpleCompletionItem(getText('activeFolderLong'), range, vscode.l10n.t("the full path of the folder the file is contained in (e.g. /Users/Development/myFolder/myFileFolder)")));
114+
completions.push(this.newSimpleCompletionItem(getText('rootName'), range, vscode.l10n.t("name of the workspace (e.g. myFolder or myWorkspace)")));
115+
completions.push(this.newSimpleCompletionItem(getText('rootPath'), range, vscode.l10n.t("file path of the workspace (e.g. /Users/Development/myWorkspace)")));
116+
completions.push(this.newSimpleCompletionItem(getText('folderName'), range, vscode.l10n.t("name of the workspace folder the file is contained in (e.g. myFolder)")));
117+
completions.push(this.newSimpleCompletionItem(getText('folderPath'), range, vscode.l10n.t("file path of the workspace folder the file is contained in (e.g. /Users/Development/myFolder)")));
118+
completions.push(this.newSimpleCompletionItem(getText('appName'), range, vscode.l10n.t("e.g. VS Code")));
119+
completions.push(this.newSimpleCompletionItem(getText('remoteName'), range, vscode.l10n.t("e.g. SSH")));
120+
completions.push(this.newSimpleCompletionItem(getText('dirty'), range, vscode.l10n.t("an indicator for when the active editor has unsaved changes")));
121+
completions.push(this.newSimpleCompletionItem(getText('separator'), range, vscode.l10n.t("a conditional separator (' - ') that only shows when surrounded by variables with values")));
124122

125123
return completions;
126124
}
@@ -134,15 +132,15 @@ export class SettingsDocument {
134132
const range = this.getReplaceRange(location, position);
135133

136134
completions.push(this.newSnippetCompletionItem({
137-
label: localize('assocLabelFile', "Files with Extension"),
138-
documentation: localize('assocDescriptionFile', "Map all files matching the glob pattern in their filename to the language with the given identifier."),
135+
label: vscode.l10n.t("Files with Extension"),
136+
documentation: vscode.l10n.t("Map all files matching the glob pattern in their filename to the language with the given identifier."),
139137
snippet: location.isAtPropertyKey ? '"*.${1:extension}": "${2:language}"' : '{ "*.${1:extension}": "${2:language}" }',
140138
range
141139
}));
142140

143141
completions.push(this.newSnippetCompletionItem({
144-
label: localize('assocLabelPath', "Files with Path"),
145-
documentation: localize('assocDescriptionPath', "Map all files matching the absolute path glob pattern in their path to the language with the given identifier."),
142+
label: vscode.l10n.t("Files with Path"),
143+
documentation: vscode.l10n.t("Map all files matching the absolute path glob pattern in their path to the language with the given identifier."),
146144
snippet: location.isAtPropertyKey ? '"/${1:path to file}/*.${2:extension}": "${3:language}"' : '{ "/${1:path to file}/*.${2:extension}": "${3:language}" }',
147145
range
148146
}));
@@ -163,43 +161,43 @@ export class SettingsDocument {
163161
const range = this.getReplaceRange(location, position);
164162

165163
completions.push(this.newSnippetCompletionItem({
166-
label: localize('fileLabel', "Files by Extension"),
167-
documentation: localize('fileDescription', "Match all files of a specific file extension."),
164+
label: vscode.l10n.t("Files by Extension"),
165+
documentation: vscode.l10n.t("Match all files of a specific file extension."),
168166
snippet: location.path.length === 2 ? '"**/*.${1:extension}": true' : '{ "**/*.${1:extension}": true }',
169167
range
170168
}));
171169

172170
completions.push(this.newSnippetCompletionItem({
173-
label: localize('filesLabel', "Files with Multiple Extensions"),
174-
documentation: localize('filesDescription', "Match all files with any of the file extensions."),
171+
label: vscode.l10n.t("Files with Multiple Extensions"),
172+
documentation: vscode.l10n.t("Match all files with any of the file extensions."),
175173
snippet: location.path.length === 2 ? '"**/*.{ext1,ext2,ext3}": true' : '{ "**/*.{ext1,ext2,ext3}": true }',
176174
range
177175
}));
178176

179177
completions.push(this.newSnippetCompletionItem({
180-
label: localize('derivedLabel', "Files with Siblings by Name"),
181-
documentation: localize('derivedDescription', "Match files that have siblings with the same name but a different extension."),
178+
label: vscode.l10n.t("Files with Siblings by Name"),
179+
documentation: vscode.l10n.t("Match files that have siblings with the same name but a different extension."),
182180
snippet: location.path.length === 2 ? '"**/*.${1:source-extension}": { "when": "$(basename).${2:target-extension}" }' : '{ "**/*.${1:source-extension}": { "when": "$(basename).${2:target-extension}" } }',
183181
range
184182
}));
185183

186184
completions.push(this.newSnippetCompletionItem({
187-
label: localize('topFolderLabel', "Folder by Name (Top Level)"),
188-
documentation: localize('topFolderDescription', "Match a top level folder with a specific name."),
185+
label: vscode.l10n.t("Folder by Name (Top Level)"),
186+
documentation: vscode.l10n.t("Match a top level folder with a specific name."),
189187
snippet: location.path.length === 2 ? '"${1:name}": true' : '{ "${1:name}": true }',
190188
range
191189
}));
192190

193191
completions.push(this.newSnippetCompletionItem({
194-
label: localize('topFoldersLabel', "Folders with Multiple Names (Top Level)"),
195-
documentation: localize('topFoldersDescription', "Match multiple top level folders."),
192+
label: vscode.l10n.t("Folders with Multiple Names (Top Level)"),
193+
documentation: vscode.l10n.t("Match multiple top level folders."),
196194
snippet: location.path.length === 2 ? '"{folder1,folder2,folder3}": true' : '{ "{folder1,folder2,folder3}": true }',
197195
range
198196
}));
199197

200198
completions.push(this.newSnippetCompletionItem({
201-
label: localize('folderLabel', "Folder by Name (Any Location)"),
202-
documentation: localize('folderDescription', "Match a folder with a specific name in any location."),
199+
label: vscode.l10n.t("Folder by Name (Any Location)"),
200+
documentation: vscode.l10n.t("Match a folder with a specific name in any location."),
203201
snippet: location.path.length === 2 ? '"**/${1:name}": true' : '{ "**/${1:name}": true }',
204202
range
205203
}));
@@ -209,8 +207,8 @@ export class SettingsDocument {
209207
else if (location.path.length === 2 && this.isCompletingPropertyValue(location, position)) {
210208
const range = this.getReplaceRange(location, position);
211209
completions.push(this.newSnippetCompletionItem({
212-
label: localize('derivedLabel', "Files with Siblings by Name"),
213-
documentation: localize('siblingsDescription', "Match files that have siblings with the same name but a different extension."),
210+
label: vscode.l10n.t("Files with Siblings by Name"),
211+
documentation: vscode.l10n.t("Match files that have siblings with the same name but a different extension."),
214212
snippet: '{ "when": "$(basename).${1:extension}" }',
215213
range
216214
}));
@@ -224,7 +222,7 @@ export class SettingsDocument {
224222
const range = this.getReplaceRange(location, position);
225223
const languages = await vscode.languages.getLanguages();
226224
return [
227-
this.newSimpleCompletionItem(JSON.stringify('${activeEditorLanguage}'), range, localize('activeEditor', "Use the language of the currently active text editor if any")),
225+
this.newSimpleCompletionItem(JSON.stringify('${activeEditorLanguage}'), range, vscode.l10n.t("Use the language of the currently active text editor if any")),
228226
...languages.map(l => this.newSimpleCompletionItem(JSON.stringify(l), range))
229227
];
230228
}

extensions/configuration-editing/yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,3 @@ jsonc-parser@^2.2.1:
1111
version "2.2.1"
1212
resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-2.2.1.tgz#db73cd59d78cce28723199466b2a03d1be1df2bc"
1313
integrity sha512-o6/yDBYccGvTz1+QFevz6l6OBZ2+fMVu2JZ9CIhzsYRX4mjaK5IyX9eldUdCmga16zlgQxyrj5pt9kzuj2C02w==
14-
15-
vscode-nls@^5.2.0:
16-
version "5.2.0"
17-
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.2.0.tgz#3cb6893dd9bd695244d8a024bdf746eea665cc3f"
18-
integrity sha512-RAaHx7B14ZU04EU31pT+rKz2/zSl7xMsfIZuo8pd+KZO6PXtQmpevpq3vxvWNcrGbdmhM/rr5Uw5Mz+NBfhVng==

0 commit comments

Comments
 (0)