Skip to content

Commit afac952

Browse files
authored
[css/json/html] move to l10n (microsoft#165725)
[css/json/html] move to l10n (for microsoft#164438)
1 parent 59faab4 commit afac952

File tree

12 files changed

+50
-91
lines changed

12 files changed

+50
-91
lines changed

extensions/css-language-features/client/src/cssClient.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,15 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { commands, CompletionItem, CompletionItemKind, ExtensionContext, languages, Position, Range, SnippetString, TextEdit, window, TextDocument, CompletionContext, CancellationToken, ProviderResult, CompletionList, FormattingOptions, workspace } from 'vscode';
6+
import { commands, CompletionItem, CompletionItemKind, ExtensionContext, languages, Position, Range, SnippetString, TextEdit, window, TextDocument, CompletionContext, CancellationToken, ProviderResult, CompletionList, FormattingOptions, workspace, l10n } from 'vscode';
77
import { Disposable, LanguageClientOptions, ProvideCompletionItemsSignature, NotificationType, BaseLanguageClient, DocumentRangeFormattingParams, DocumentRangeFormattingRequest } from 'vscode-languageclient';
8-
import * as nls from 'vscode-nls';
98
import { getCustomDataSource } from './customData';
109
import { RequestService, serveFileSystemRequests } from './requests';
1110

1211
namespace CustomDataChangedNotification {
1312
export const type: NotificationType<string[]> = new NotificationType('css/customDataChanged');
1413
}
1514

16-
const localize = nls.loadMessageBundle();
17-
1815
export type LanguageClientConstructor = (name: string, description: string, clientOptions: LanguageClientOptions) => BaseLanguageClient;
1916

2017
export interface Runtime {
@@ -98,7 +95,7 @@ export async function startClient(context: ExtensionContext, newLanguageClient:
9895
};
9996

10097
// Create the language client and start the client.
101-
const client = newLanguageClient('css', localize('cssserver.name', 'CSS Language Server'), clientOptions);
98+
const client = newLanguageClient('css', l10n.t('CSS Language Server'), clientOptions);
10299
client.registerProposedFeatures();
103100

104101
await client.start();
@@ -132,13 +129,13 @@ export async function startClient(context: ExtensionContext, newLanguageClient:
132129
const beginProposal = new CompletionItem('#region', CompletionItemKind.Snippet);
133130
beginProposal.range = range; TextEdit.replace(range, '/* #region */');
134131
beginProposal.insertText = new SnippetString('/* #region $1*/');
135-
beginProposal.documentation = localize('folding.start', 'Folding Region Start');
132+
beginProposal.documentation = l10n.t('Folding Region Start');
136133
beginProposal.filterText = match[2];
137134
beginProposal.sortText = 'za';
138135
const endProposal = new CompletionItem('#endregion', CompletionItemKind.Snippet);
139136
endProposal.range = range;
140137
endProposal.insertText = '/* #endregion */';
141-
endProposal.documentation = localize('folding.end', 'Folding Region End');
138+
endProposal.documentation = l10n.t('Folding Region End');
142139
endProposal.sortText = 'zb';
143140
endProposal.filterText = match[2];
144141
return [beginProposal, endProposal];
@@ -154,15 +151,15 @@ export async function startClient(context: ExtensionContext, newLanguageClient:
154151
const textEditor = window.activeTextEditor;
155152
if (textEditor && textEditor.document.uri.toString() === uri) {
156153
if (textEditor.document.version !== documentVersion) {
157-
window.showInformationMessage(`CSS fix is outdated and can't be applied to the document.`);
154+
window.showInformationMessage(l10n.t('CSS fix is outdated and can\'t be applied to the document.'));
158155
}
159156
textEditor.edit(mutator => {
160157
for (const edit of edits) {
161158
mutator.replace(client.protocol2CodeConverter.asRange(edit.range), edit.newText);
162159
}
163160
}).then(success => {
164161
if (!success) {
165-
window.showErrorMessage('Failed to apply CSS fix to the document. Please consider opening an issue with steps to reproduce.');
162+
window.showErrorMessage(l10n.t('Failed to apply CSS fix to the document. Please consider opening an issue with steps to reproduce.'));
166163
}
167164
});
168165
}

extensions/css-language-features/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,6 @@
995995
},
996996
"dependencies": {
997997
"vscode-languageclient": "^8.1.0-next.1",
998-
"vscode-nls": "^5.2.0",
999998
"vscode-uri": "^3.0.6"
1000999
},
10011000
"devDependencies": {

extensions/css-language-features/yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,6 @@ [email protected]:
6767
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.17.2.tgz#b2c2e7de405ad3d73a883e91989b850170ffc4f2"
6868
integrity sha512-zHhCWatviizPIq9B7Vh9uvrH6x3sK8itC84HkamnBWoDFJtzBf7SWlpLCZUit72b3os45h6RWQNC9xHRDF8dRA==
6969

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==
74-
7570
vscode-uri@^3.0.6:
7671
version "3.0.6"
7772
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-3.0.6.tgz#5e6e2e1a4170543af30151b561a41f71db1d6f91"

extensions/html-language-features/client/src/htmlClient.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import * as nls from 'vscode-nls';
7-
const localize = nls.loadMessageBundle();
86

97
import {
108
languages, ExtensionContext, Position, TextDocument, Range, CompletionItem, CompletionItemKind, SnippetString, workspace, extensions,
119
Disposable, FormattingOptions, CancellationToken, ProviderResult, TextEdit, CompletionContext, CompletionList, SemanticTokensLegend,
12-
DocumentSemanticTokensProvider, DocumentRangeSemanticTokensProvider, SemanticTokens, window, commands, OutputChannel
10+
DocumentSemanticTokensProvider, DocumentRangeSemanticTokensProvider, SemanticTokens, window, commands, OutputChannel, l10n
1311
} from 'vscode';
1412
import {
1513
LanguageClientOptions, RequestType, DocumentRangeFormattingParams,
@@ -75,7 +73,7 @@ export interface TelemetryReporter {
7573

7674
export type LanguageClientConstructor = (name: string, description: string, clientOptions: LanguageClientOptions) => BaseLanguageClient;
7775

78-
export const languageServerDescription = localize('htmlserver.name', 'HTML Language Server');
76+
export const languageServerDescription = l10n.t('HTML Language Server');
7977

8078
export interface Runtime {
8179
TextDecoder: { new(encoding?: string): { decode(buffer: ArrayBuffer): string } };
@@ -107,8 +105,8 @@ export async function startClient(context: ExtensionContext, newLanguageClient:
107105
if (e && languageParticipants.hasLanguage(e.document.languageId)) {
108106
context.globalState.update(promptForLinkedEditingKey, false);
109107
activeEditorListener.dispose();
110-
const configure = localize('configureButton', 'Configure');
111-
const res = await window.showInformationMessage(localize('linkedEditingQuestion', 'VS Code now has built-in support for auto-renaming tags. Do you want to enable it?'), configure);
108+
const configure = l10n.t('Configure');
109+
const res = await window.showInformationMessage(l10n.t('VS Code now has built-in support for auto-renaming tags. Do you want to enable it?'), configure);
112110
if (res === configure) {
113111
commands.executeCommand('workbench.action.openSettings', SettingIds.linkedEditing);
114112
}
@@ -299,14 +297,14 @@ async function startClientWithParticipants(languageParticipants: LanguagePartici
299297
const beginProposal = new CompletionItem('#region', CompletionItemKind.Snippet);
300298
beginProposal.range = range;
301299
beginProposal.insertText = new SnippetString('<!-- #region $1-->');
302-
beginProposal.documentation = localize('folding.start', 'Folding Region Start');
300+
beginProposal.documentation = l10n.t('Folding Region Start');
303301
beginProposal.filterText = match[2];
304302
beginProposal.sortText = 'za';
305303
results.push(beginProposal);
306304
const endProposal = new CompletionItem('#endregion', CompletionItemKind.Snippet);
307305
endProposal.range = range;
308306
endProposal.insertText = new SnippetString('<!-- #endregion -->');
309-
endProposal.documentation = localize('folding.end', 'Folding Region End');
307+
endProposal.documentation = l10n.t('Folding Region End');
310308
endProposal.filterText = match[2];
311309
endProposal.sortText = 'zb';
312310
results.push(endProposal);
@@ -331,7 +329,7 @@ async function startClientWithParticipants(languageParticipants: LanguagePartici
331329
'</body>',
332330
'</html>'].join('\n');
333331
snippetProposal.insertText = new SnippetString(content);
334-
snippetProposal.documentation = localize('folding.html', 'Simple HTML5 starting point');
332+
snippetProposal.documentation = l10n.t('Simple HTML5 starting point');
335333
snippetProposal.filterText = match2[2];
336334
snippetProposal.sortText = 'za';
337335
results.push(snippetProposal);

extensions/html-language-features/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@
260260
"dependencies": {
261261
"@vscode/extension-telemetry": "0.6.2",
262262
"vscode-languageclient": "^8.1.0-next.1",
263-
"vscode-nls": "^5.2.0",
264263
"vscode-uri": "^3.0.6"
265264
},
266265
"devDependencies": {

extensions/html-language-features/server/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"vscode-html-languageservice": "^5.0.2",
1414
"vscode-languageserver": "^8.1.0-next.1",
1515
"vscode-languageserver-textdocument": "^1.0.7",
16-
"vscode-nls": "^5.2.0",
1716
"vscode-uri": "^3.0.6"
1817
},
1918
"devDependencies": {

extensions/html-language-features/server/yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ vscode-nls@^5.2.0:
6767
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.2.0.tgz#3cb6893dd9bd695244d8a024bdf746eea665cc3f"
6868
integrity sha512-RAaHx7B14ZU04EU31pT+rKz2/zSl7xMsfIZuo8pd+KZO6PXtQmpevpq3vxvWNcrGbdmhM/rr5Uw5Mz+NBfhVng==
6969

70-
vscode-uri@^3.0.6, vscode-uri@^3.0.4:
70+
vscode-uri@^3.0.4, vscode-uri@^3.0.6:
7171
version "3.0.6"
7272
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-3.0.6.tgz#5e6e2e1a4170543af30151b561a41f71db1d6f91"
7373
integrity sha512-fmL7V1eiDBFRRnu+gfRWTzyPpNIHJTc4mWnFkwBUmO9U3KPgJAmTx7oxi2bl/Rh6HLdU7+4C9wlj0k2E4AdKFQ==

extensions/html-language-features/yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,6 @@ [email protected]:
111111
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.17.2.tgz#b2c2e7de405ad3d73a883e91989b850170ffc4f2"
112112
integrity sha512-zHhCWatviizPIq9B7Vh9uvrH6x3sK8itC84HkamnBWoDFJtzBf7SWlpLCZUit72b3os45h6RWQNC9xHRDF8dRA==
113113

114-
vscode-nls@^5.2.0:
115-
version "5.2.0"
116-
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.2.0.tgz#3cb6893dd9bd695244d8a024bdf746eea665cc3f"
117-
integrity sha512-RAaHx7B14ZU04EU31pT+rKz2/zSl7xMsfIZuo8pd+KZO6PXtQmpevpq3vxvWNcrGbdmhM/rr5Uw5Mz+NBfhVng==
118-
119114
vscode-uri@^3.0.6:
120115
version "3.0.6"
121116
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-3.0.6.tgz#5e6e2e1a4170543af30151b561a41f71db1d6f91"

extensions/json-language-features/client/src/jsonClient.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22
* Copyright (c) Microsoft Corporation. All rights reserved.
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
5-
import * as nls from 'vscode-nls';
6-
7-
const localize = nls.loadMessageBundle();
85

96
export type JSONLanguageStatus = { schemas: string[] };
107

118
import {
129
workspace, window, languages, commands, ExtensionContext, extensions, Uri, ColorInformation,
1310
Diagnostic, StatusBarAlignment, TextEditor, TextDocument, FormattingOptions, CancellationToken, FoldingRange,
14-
ProviderResult, TextEdit, Range, Position, Disposable, CompletionItem, CompletionList, CompletionContext, Hover, MarkdownString, FoldingContext, DocumentSymbol, SymbolInformation
11+
ProviderResult, TextEdit, Range, Position, Disposable, CompletionItem, CompletionList, CompletionContext, Hover, MarkdownString, FoldingContext, DocumentSymbol, SymbolInformation, l10n
1512
} from 'vscode';
1613
import {
1714
LanguageClientOptions, RequestType, NotificationType,
@@ -106,7 +103,7 @@ export interface SchemaRequestService {
106103
clearCache?(): Promise<string[]>;
107104
}
108105

109-
export const languageServerDescription = localize('jsonserver.name', 'JSON Language Server');
106+
export const languageServerDescription = l10n.t('JSON Language Server');
110107

111108
let resultLimit = 5000;
112109
let jsonFoldingLimit = 5000;
@@ -121,7 +118,7 @@ export async function startClient(context: ExtensionContext, newLanguageClient:
121118
const documentSelector = ['json', 'jsonc'];
122119

123120
const schemaResolutionErrorStatusBarItem = window.createStatusBarItem('status.json.resolveError', StatusBarAlignment.Right, 0);
124-
schemaResolutionErrorStatusBarItem.name = localize('json.resolveError', "JSON: Schema Resolution Error");
121+
schemaResolutionErrorStatusBarItem.name = l10n.t('JSON: Schema Resolution Error');
125122
schemaResolutionErrorStatusBarItem.text = '$(alert)';
126123
toDispose.push(schemaResolutionErrorStatusBarItem);
127124

@@ -139,7 +136,7 @@ export async function startClient(context: ExtensionContext, newLanguageClient:
139136
const cachedSchemas = await runtime.schemaRequests.clearCache();
140137
await client.sendNotification(SchemaContentChangeNotification.type, cachedSchemas);
141138
}
142-
window.showInformationMessage(localize('json.clearCache.completed', "JSON schema cache cleared."));
139+
window.showInformationMessage(l10n.t('JSON schema cache cleared.'));
143140
}));
144141

145142
// Options to control the language client
@@ -277,7 +274,7 @@ export async function startClient(context: ExtensionContext, newLanguageClient:
277274
client.onRequest(VSCodeContentRequest.type, (uriPath: string) => {
278275
const uri = Uri.parse(uriPath);
279276
if (uri.scheme === 'untitled') {
280-
return Promise.reject(new ResponseError(3, localize('untitled.schema', 'Unable to load {0}', uri.toString())));
277+
return Promise.reject(new ResponseError(3, l10n.t('Unable to load {0}', uri.toString())));
281278
}
282279
if (uri.scheme !== 'http' && uri.scheme !== 'https') {
283280
return workspace.openTextDocument(uri).then(doc => {
@@ -301,7 +298,7 @@ export async function startClient(context: ExtensionContext, newLanguageClient:
301298
return Promise.reject(new ResponseError(4, e.toString()));
302299
});
303300
} else {
304-
return Promise.reject(new ResponseError(1, localize('schemaDownloadDisabled', 'Downloading schemas is disabled through setting \'{0}\'', SettingIds.enableSchemaDownload)));
301+
return Promise.reject(new ResponseError(1, l10n.t('Downloading schemas is disabled through setting \'{0}\'', SettingIds.enableSchemaDownload)));
305302
}
306303
});
307304

@@ -417,11 +414,11 @@ export async function startClient(context: ExtensionContext, newLanguageClient:
417414
function updateSchemaDownloadSetting() {
418415
schemaDownloadEnabled = workspace.getConfiguration().get(SettingIds.enableSchemaDownload) !== false;
419416
if (schemaDownloadEnabled) {
420-
schemaResolutionErrorStatusBarItem.tooltip = localize('json.schemaResolutionErrorMessage', 'Unable to resolve schema. Click to retry.');
417+
schemaResolutionErrorStatusBarItem.tooltip = l10n.t('Unable to resolve schema. Click to retry.');
421418
schemaResolutionErrorStatusBarItem.command = '_json.retryResolveSchema';
422419
handleRetryResolveSchemaCommand();
423420
} else {
424-
schemaResolutionErrorStatusBarItem.tooltip = localize('json.schemaResolutionDisabledMessage', 'Downloading schemas is disabled. Click to configure.');
421+
schemaResolutionErrorStatusBarItem.tooltip = l10n.t('Downloading schemas is disabled. Click to configure.');
425422
schemaResolutionErrorStatusBarItem.command = { command: 'workbench.action.openSettings', arguments: [SettingIds.enableSchemaDownload], title: '' };
426423
}
427424
}

0 commit comments

Comments
 (0)