Skip to content

Commit

Permalink
[css/json/html] move to l10n (#165725)
Browse files Browse the repository at this point in the history
[css/json/html] move to l10n (for #164438)
  • Loading branch information
aeschli committed Nov 8, 2022
1 parent 59faab4 commit afac952
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 91 deletions.
15 changes: 6 additions & 9 deletions extensions/css-language-features/client/src/cssClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

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

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

const localize = nls.loadMessageBundle();

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

export interface Runtime {
Expand Down Expand Up @@ -98,7 +95,7 @@ export async function startClient(context: ExtensionContext, newLanguageClient:
};

// Create the language client and start the client.
const client = newLanguageClient('css', localize('cssserver.name', 'CSS Language Server'), clientOptions);
const client = newLanguageClient('css', l10n.t('CSS Language Server'), clientOptions);
client.registerProposedFeatures();

await client.start();
Expand Down Expand Up @@ -132,13 +129,13 @@ export async function startClient(context: ExtensionContext, newLanguageClient:
const beginProposal = new CompletionItem('#region', CompletionItemKind.Snippet);
beginProposal.range = range; TextEdit.replace(range, '/* #region */');
beginProposal.insertText = new SnippetString('/* #region $1*/');
beginProposal.documentation = localize('folding.start', 'Folding Region Start');
beginProposal.documentation = l10n.t('Folding Region Start');
beginProposal.filterText = match[2];
beginProposal.sortText = 'za';
const endProposal = new CompletionItem('#endregion', CompletionItemKind.Snippet);
endProposal.range = range;
endProposal.insertText = '/* #endregion */';
endProposal.documentation = localize('folding.end', 'Folding Region End');
endProposal.documentation = l10n.t('Folding Region End');
endProposal.sortText = 'zb';
endProposal.filterText = match[2];
return [beginProposal, endProposal];
Expand All @@ -154,15 +151,15 @@ export async function startClient(context: ExtensionContext, newLanguageClient:
const textEditor = window.activeTextEditor;
if (textEditor && textEditor.document.uri.toString() === uri) {
if (textEditor.document.version !== documentVersion) {
window.showInformationMessage(`CSS fix is outdated and can't be applied to the document.`);
window.showInformationMessage(l10n.t('CSS fix is outdated and can\'t be applied to the document.'));
}
textEditor.edit(mutator => {
for (const edit of edits) {
mutator.replace(client.protocol2CodeConverter.asRange(edit.range), edit.newText);
}
}).then(success => {
if (!success) {
window.showErrorMessage('Failed to apply CSS fix to the document. Please consider opening an issue with steps to reproduce.');
window.showErrorMessage(l10n.t('Failed to apply CSS fix to the document. Please consider opening an issue with steps to reproduce.'));
}
});
}
Expand Down
1 change: 0 additions & 1 deletion extensions/css-language-features/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,6 @@
},
"dependencies": {
"vscode-languageclient": "^8.1.0-next.1",
"vscode-nls": "^5.2.0",
"vscode-uri": "^3.0.6"
},
"devDependencies": {
Expand Down
5 changes: 0 additions & 5 deletions extensions/css-language-features/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ vscode-languageserver-types@3.17.2:
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.17.2.tgz#b2c2e7de405ad3d73a883e91989b850170ffc4f2"
integrity sha512-zHhCWatviizPIq9B7Vh9uvrH6x3sK8itC84HkamnBWoDFJtzBf7SWlpLCZUit72b3os45h6RWQNC9xHRDF8dRA==

vscode-nls@^5.2.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.2.0.tgz#3cb6893dd9bd695244d8a024bdf746eea665cc3f"
integrity sha512-RAaHx7B14ZU04EU31pT+rKz2/zSl7xMsfIZuo8pd+KZO6PXtQmpevpq3vxvWNcrGbdmhM/rr5Uw5Mz+NBfhVng==

vscode-uri@^3.0.6:
version "3.0.6"
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-3.0.6.tgz#5e6e2e1a4170543af30151b561a41f71db1d6f91"
Expand Down
16 changes: 7 additions & 9 deletions extensions/html-language-features/client/src/htmlClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

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

import {
languages, ExtensionContext, Position, TextDocument, Range, CompletionItem, CompletionItemKind, SnippetString, workspace, extensions,
Disposable, FormattingOptions, CancellationToken, ProviderResult, TextEdit, CompletionContext, CompletionList, SemanticTokensLegend,
DocumentSemanticTokensProvider, DocumentRangeSemanticTokensProvider, SemanticTokens, window, commands, OutputChannel
DocumentSemanticTokensProvider, DocumentRangeSemanticTokensProvider, SemanticTokens, window, commands, OutputChannel, l10n
} from 'vscode';
import {
LanguageClientOptions, RequestType, DocumentRangeFormattingParams,
Expand Down Expand Up @@ -75,7 +73,7 @@ export interface TelemetryReporter {

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

export const languageServerDescription = localize('htmlserver.name', 'HTML Language Server');
export const languageServerDescription = l10n.t('HTML Language Server');

export interface Runtime {
TextDecoder: { new(encoding?: string): { decode(buffer: ArrayBuffer): string } };
Expand Down Expand Up @@ -107,8 +105,8 @@ export async function startClient(context: ExtensionContext, newLanguageClient:
if (e && languageParticipants.hasLanguage(e.document.languageId)) {
context.globalState.update(promptForLinkedEditingKey, false);
activeEditorListener.dispose();
const configure = localize('configureButton', 'Configure');
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);
const configure = l10n.t('Configure');
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);
if (res === configure) {
commands.executeCommand('workbench.action.openSettings', SettingIds.linkedEditing);
}
Expand Down Expand Up @@ -299,14 +297,14 @@ async function startClientWithParticipants(languageParticipants: LanguagePartici
const beginProposal = new CompletionItem('#region', CompletionItemKind.Snippet);
beginProposal.range = range;
beginProposal.insertText = new SnippetString('<!-- #region $1-->');
beginProposal.documentation = localize('folding.start', 'Folding Region Start');
beginProposal.documentation = l10n.t('Folding Region Start');
beginProposal.filterText = match[2];
beginProposal.sortText = 'za';
results.push(beginProposal);
const endProposal = new CompletionItem('#endregion', CompletionItemKind.Snippet);
endProposal.range = range;
endProposal.insertText = new SnippetString('<!-- #endregion -->');
endProposal.documentation = localize('folding.end', 'Folding Region End');
endProposal.documentation = l10n.t('Folding Region End');
endProposal.filterText = match[2];
endProposal.sortText = 'zb';
results.push(endProposal);
Expand All @@ -331,7 +329,7 @@ async function startClientWithParticipants(languageParticipants: LanguagePartici
'</body>',
'</html>'].join('\n');
snippetProposal.insertText = new SnippetString(content);
snippetProposal.documentation = localize('folding.html', 'Simple HTML5 starting point');
snippetProposal.documentation = l10n.t('Simple HTML5 starting point');
snippetProposal.filterText = match2[2];
snippetProposal.sortText = 'za';
results.push(snippetProposal);
Expand Down
1 change: 0 additions & 1 deletion extensions/html-language-features/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@
"dependencies": {
"@vscode/extension-telemetry": "0.6.2",
"vscode-languageclient": "^8.1.0-next.1",
"vscode-nls": "^5.2.0",
"vscode-uri": "^3.0.6"
},
"devDependencies": {
Expand Down
1 change: 0 additions & 1 deletion extensions/html-language-features/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"vscode-html-languageservice": "^5.0.2",
"vscode-languageserver": "^8.1.0-next.1",
"vscode-languageserver-textdocument": "^1.0.7",
"vscode-nls": "^5.2.0",
"vscode-uri": "^3.0.6"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion extensions/html-language-features/server/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ vscode-nls@^5.2.0:
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.2.0.tgz#3cb6893dd9bd695244d8a024bdf746eea665cc3f"
integrity sha512-RAaHx7B14ZU04EU31pT+rKz2/zSl7xMsfIZuo8pd+KZO6PXtQmpevpq3vxvWNcrGbdmhM/rr5Uw5Mz+NBfhVng==

vscode-uri@^3.0.6, vscode-uri@^3.0.4:
vscode-uri@^3.0.4, vscode-uri@^3.0.6:
version "3.0.6"
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-3.0.6.tgz#5e6e2e1a4170543af30151b561a41f71db1d6f91"
integrity sha512-fmL7V1eiDBFRRnu+gfRWTzyPpNIHJTc4mWnFkwBUmO9U3KPgJAmTx7oxi2bl/Rh6HLdU7+4C9wlj0k2E4AdKFQ==
5 changes: 0 additions & 5 deletions extensions/html-language-features/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,6 @@ vscode-languageserver-types@3.17.2:
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.17.2.tgz#b2c2e7de405ad3d73a883e91989b850170ffc4f2"
integrity sha512-zHhCWatviizPIq9B7Vh9uvrH6x3sK8itC84HkamnBWoDFJtzBf7SWlpLCZUit72b3os45h6RWQNC9xHRDF8dRA==

vscode-nls@^5.2.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.2.0.tgz#3cb6893dd9bd695244d8a024bdf746eea665cc3f"
integrity sha512-RAaHx7B14ZU04EU31pT+rKz2/zSl7xMsfIZuo8pd+KZO6PXtQmpevpq3vxvWNcrGbdmhM/rr5Uw5Mz+NBfhVng==

vscode-uri@^3.0.6:
version "3.0.6"
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-3.0.6.tgz#5e6e2e1a4170543af30151b561a41f71db1d6f91"
Expand Down
19 changes: 8 additions & 11 deletions extensions/json-language-features/client/src/jsonClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as nls from 'vscode-nls';

const localize = nls.loadMessageBundle();

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

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

export const languageServerDescription = localize('jsonserver.name', 'JSON Language Server');
export const languageServerDescription = l10n.t('JSON Language Server');

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

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

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

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

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

0 comments on commit afac952

Please sign in to comment.