Skip to content

Commit 8a37410

Browse files
authored
Adopt l10n for extension-editing (microsoft#165523)
For microsoft#164438
1 parent 09f6753 commit 8a37410

File tree

5 files changed

+20
-22
lines changed

5 files changed

+20
-22
lines changed

Diff for: .eslintplugin/code-no-unexternalized-strings.ts

+8
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,16 @@ export = new class NoUnexternalizedStrings implements eslint.Rule.RuleModule {
138138
return {
139139
['Literal']: (node: any) => collectDoubleQuotedStrings(node),
140140
['ExpressionStatement[directive] Literal:exit']: (node: any) => doubleQuotedStringLiterals.delete(node),
141+
142+
// localize(...)
141143
['CallExpression[callee.type="MemberExpression"][callee.object.name="nls"][callee.property.name="localize"]:exit']: (node: any) => visitLocalizeCall(node),
144+
145+
// vscode.l10n.t(...)
142146
['CallExpression[callee.type="MemberExpression"][callee.object.property.name="l10n"][callee.property.name="t"]:exit']: (node: any) => visitL10NCall(node),
147+
148+
// l10n.t(...)
149+
['CallExpression[callee.object.name="l10n"][callee.property.name="t"]:exit']: (node: any) => visitL10NCall(node),
150+
143151
['CallExpression[callee.name="localize"][arguments.length>=2]:exit']: (node: any) => visitLocalizeCall(node),
144152
['Program:exit']: reportBadStringsAndBadKeys,
145153
};

Diff for: extensions/extension-editing/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
"dependencies": {
2929
"jsonc-parser": "^2.2.1",
3030
"markdown-it": "^12.3.2",
31-
"parse5": "^3.0.2",
32-
"vscode-nls": "^5.2.0"
31+
"parse5": "^3.0.2"
3332
},
3433
"contributes": {
3534
"jsonValidation": [

Diff for: extensions/extension-editing/src/extensionLinter.ts

+9-11
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66
import * as path from 'path';
77
import * as fs from 'fs';
88
import { URL } from 'url';
9-
import * as nls from 'vscode-nls';
10-
const localize = nls.loadMessageBundle();
119

1210
import { parseTree, findNodeAtLocation, Node as JsonNode, getNodeValue } from 'jsonc-parser';
1311
import * as MarkdownItType from 'markdown-it';
1412

15-
import { languages, workspace, Disposable, TextDocument, Uri, Diagnostic, Range, DiagnosticSeverity, Position, env } from 'vscode';
13+
import { languages, workspace, Disposable, TextDocument, Uri, Diagnostic, Range, DiagnosticSeverity, Position, env, l10n } from 'vscode';
1614

1715
const product = JSON.parse(fs.readFileSync(path.join(env.appRoot, 'product.json'), { encoding: 'utf-8' }));
1816
const allowedBadgeProviders: string[] = (product.extensionAllowedBadgeProviders || []).map((s: string) => s.toLowerCase());
@@ -23,14 +21,14 @@ function isTrustedSVGSource(uri: Uri): boolean {
2321
return allowedBadgeProviders.includes(uri.authority.toLowerCase()) || allowedBadgeProvidersRegex.some(r => r.test(uri.toString()));
2422
}
2523

26-
const httpsRequired = localize('httpsRequired', "Images must use the HTTPS protocol.");
27-
const svgsNotValid = localize('svgsNotValid', "SVGs are not a valid image source.");
28-
const embeddedSvgsNotValid = localize('embeddedSvgsNotValid', "Embedded SVGs are not a valid image source.");
29-
const dataUrlsNotValid = localize('dataUrlsNotValid', "Data URLs are not a valid image source.");
30-
const relativeUrlRequiresHttpsRepository = localize('relativeUrlRequiresHttpsRepository', "Relative image URLs require a repository with HTTPS protocol to be specified in the package.json.");
31-
const relativeIconUrlRequiresHttpsRepository = localize('relativeIconUrlRequiresHttpsRepository', "An icon requires a repository with HTTPS protocol to be specified in this package.json.");
32-
const relativeBadgeUrlRequiresHttpsRepository = localize('relativeBadgeUrlRequiresHttpsRepository', "Relative badge URLs require a repository with HTTPS protocol to be specified in this package.json.");
33-
const apiProposalNotListed = localize('apiProposalNotListed', "This proposal cannot be used because for this extension the product defines a fixed set of API proposals. You can test your extension but before publishing you MUST reach out to the VS Code team.");
24+
const httpsRequired = l10n.t("Images must use the HTTPS protocol.");
25+
const svgsNotValid = l10n.t("SVGs are not a valid image source.");
26+
const embeddedSvgsNotValid = l10n.t("Embedded SVGs are not a valid image source.");
27+
const dataUrlsNotValid = l10n.t("Data URLs are not a valid image source.");
28+
const relativeUrlRequiresHttpsRepository = l10n.t("Relative image URLs require a repository with HTTPS protocol to be specified in the package.json.");
29+
const relativeIconUrlRequiresHttpsRepository = l10n.t("An icon requires a repository with HTTPS protocol to be specified in this package.json.");
30+
const relativeBadgeUrlRequiresHttpsRepository = l10n.t("Relative badge URLs require a repository with HTTPS protocol to be specified in this package.json.");
31+
const apiProposalNotListed = l10n.t("This proposal cannot be used because for this extension the product defines a fixed set of API proposals. You can test your extension but before publishing you MUST reach out to the VS Code team.");
3432

3533
enum Context {
3634
ICON,

Diff for: extensions/extension-editing/src/packageDocumentHelper.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55

66
import * as vscode from 'vscode';
77
import { getLocation, Location } from 'jsonc-parser';
8-
import * as nls from 'vscode-nls';
98

10-
const localize = nls.loadMessageBundle();
119

1210
export class PackageDocument {
1311

@@ -40,8 +38,8 @@ export class PackageDocument {
4038
}
4139

4240
return Promise.resolve([this.newSnippetCompletionItem({
43-
label: localize('languageSpecificEditorSettings', "Language specific editor settings"),
44-
documentation: localize('languageSpecificEditorSettingsDescription', "Override editor settings for language"),
41+
label: vscode.l10n.t("Language specific editor settings"),
42+
documentation: vscode.l10n.t("Override editor settings for language"),
4543
snippet,
4644
range
4745
})]);

Diff for: extensions/extension-editing/yarn.lock

-5
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,3 @@ uc.micro@^1.0.1, uc.micro@^1.0.5:
6666
version "1.0.6"
6767
resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.6.tgz#9c411a802a409a91fc6cf74081baba34b24499ac"
6868
integrity sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==
69-
70-
vscode-nls@^5.2.0:
71-
version "5.2.0"
72-
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.2.0.tgz#3cb6893dd9bd695244d8a024bdf746eea665cc3f"
73-
integrity sha512-RAaHx7B14ZU04EU31pT+rKz2/zSl7xMsfIZuo8pd+KZO6PXtQmpevpq3vxvWNcrGbdmhM/rr5Uw5Mz+NBfhVng==

0 commit comments

Comments
 (0)