mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-20 02:08:47 +00:00
[css/json/html] move to l10n (#165725)
[css/json/html] move to l10n (for #164438)
This commit is contained in:
committed by
GitHub
parent
59faab44cd
commit
afac9524b6
@@ -3,9 +3,8 @@
|
|||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
* 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 { Disposable, LanguageClientOptions, ProvideCompletionItemsSignature, NotificationType, BaseLanguageClient, DocumentRangeFormattingParams, DocumentRangeFormattingRequest } from 'vscode-languageclient';
|
||||||
import * as nls from 'vscode-nls';
|
|
||||||
import { getCustomDataSource } from './customData';
|
import { getCustomDataSource } from './customData';
|
||||||
import { RequestService, serveFileSystemRequests } from './requests';
|
import { RequestService, serveFileSystemRequests } from './requests';
|
||||||
|
|
||||||
@@ -13,8 +12,6 @@ namespace CustomDataChangedNotification {
|
|||||||
export const type: NotificationType<string[]> = new NotificationType('css/customDataChanged');
|
export const type: NotificationType<string[]> = new NotificationType('css/customDataChanged');
|
||||||
}
|
}
|
||||||
|
|
||||||
const localize = nls.loadMessageBundle();
|
|
||||||
|
|
||||||
export type LanguageClientConstructor = (name: string, description: string, clientOptions: LanguageClientOptions) => BaseLanguageClient;
|
export type LanguageClientConstructor = (name: string, description: string, clientOptions: LanguageClientOptions) => BaseLanguageClient;
|
||||||
|
|
||||||
export interface Runtime {
|
export interface Runtime {
|
||||||
@@ -98,7 +95,7 @@ export async function startClient(context: ExtensionContext, newLanguageClient:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Create the language client and start the client.
|
// 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();
|
client.registerProposedFeatures();
|
||||||
|
|
||||||
await client.start();
|
await client.start();
|
||||||
@@ -132,13 +129,13 @@ export async function startClient(context: ExtensionContext, newLanguageClient:
|
|||||||
const beginProposal = new CompletionItem('#region', CompletionItemKind.Snippet);
|
const beginProposal = new CompletionItem('#region', CompletionItemKind.Snippet);
|
||||||
beginProposal.range = range; TextEdit.replace(range, '/* #region */');
|
beginProposal.range = range; TextEdit.replace(range, '/* #region */');
|
||||||
beginProposal.insertText = new SnippetString('/* #region $1*/');
|
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.filterText = match[2];
|
||||||
beginProposal.sortText = 'za';
|
beginProposal.sortText = 'za';
|
||||||
const endProposal = new CompletionItem('#endregion', CompletionItemKind.Snippet);
|
const endProposal = new CompletionItem('#endregion', CompletionItemKind.Snippet);
|
||||||
endProposal.range = range;
|
endProposal.range = range;
|
||||||
endProposal.insertText = '/* #endregion */';
|
endProposal.insertText = '/* #endregion */';
|
||||||
endProposal.documentation = localize('folding.end', 'Folding Region End');
|
endProposal.documentation = l10n.t('Folding Region End');
|
||||||
endProposal.sortText = 'zb';
|
endProposal.sortText = 'zb';
|
||||||
endProposal.filterText = match[2];
|
endProposal.filterText = match[2];
|
||||||
return [beginProposal, endProposal];
|
return [beginProposal, endProposal];
|
||||||
@@ -154,7 +151,7 @@ export async function startClient(context: ExtensionContext, newLanguageClient:
|
|||||||
const textEditor = window.activeTextEditor;
|
const textEditor = window.activeTextEditor;
|
||||||
if (textEditor && textEditor.document.uri.toString() === uri) {
|
if (textEditor && textEditor.document.uri.toString() === uri) {
|
||||||
if (textEditor.document.version !== documentVersion) {
|
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 => {
|
textEditor.edit(mutator => {
|
||||||
for (const edit of edits) {
|
for (const edit of edits) {
|
||||||
@@ -162,7 +159,7 @@ export async function startClient(context: ExtensionContext, newLanguageClient:
|
|||||||
}
|
}
|
||||||
}).then(success => {
|
}).then(success => {
|
||||||
if (!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.'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -995,7 +995,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"vscode-languageclient": "^8.1.0-next.1",
|
"vscode-languageclient": "^8.1.0-next.1",
|
||||||
"vscode-nls": "^5.2.0",
|
|
||||||
"vscode-uri": "^3.0.6"
|
"vscode-uri": "^3.0.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -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"
|
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.17.2.tgz#b2c2e7de405ad3d73a883e91989b850170ffc4f2"
|
||||||
integrity sha512-zHhCWatviizPIq9B7Vh9uvrH6x3sK8itC84HkamnBWoDFJtzBf7SWlpLCZUit72b3os45h6RWQNC9xHRDF8dRA==
|
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:
|
vscode-uri@^3.0.6:
|
||||||
version "3.0.6"
|
version "3.0.6"
|
||||||
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-3.0.6.tgz#5e6e2e1a4170543af30151b561a41f71db1d6f91"
|
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-3.0.6.tgz#5e6e2e1a4170543af30151b561a41f71db1d6f91"
|
||||||
|
|||||||
@@ -3,13 +3,11 @@
|
|||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
* 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 {
|
import {
|
||||||
languages, ExtensionContext, Position, TextDocument, Range, CompletionItem, CompletionItemKind, SnippetString, workspace, extensions,
|
languages, ExtensionContext, Position, TextDocument, Range, CompletionItem, CompletionItemKind, SnippetString, workspace, extensions,
|
||||||
Disposable, FormattingOptions, CancellationToken, ProviderResult, TextEdit, CompletionContext, CompletionList, SemanticTokensLegend,
|
Disposable, FormattingOptions, CancellationToken, ProviderResult, TextEdit, CompletionContext, CompletionList, SemanticTokensLegend,
|
||||||
DocumentSemanticTokensProvider, DocumentRangeSemanticTokensProvider, SemanticTokens, window, commands, OutputChannel
|
DocumentSemanticTokensProvider, DocumentRangeSemanticTokensProvider, SemanticTokens, window, commands, OutputChannel, l10n
|
||||||
} from 'vscode';
|
} from 'vscode';
|
||||||
import {
|
import {
|
||||||
LanguageClientOptions, RequestType, DocumentRangeFormattingParams,
|
LanguageClientOptions, RequestType, DocumentRangeFormattingParams,
|
||||||
@@ -75,7 +73,7 @@ export interface TelemetryReporter {
|
|||||||
|
|
||||||
export type LanguageClientConstructor = (name: string, description: string, clientOptions: LanguageClientOptions) => BaseLanguageClient;
|
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 {
|
export interface Runtime {
|
||||||
TextDecoder: { new(encoding?: string): { decode(buffer: ArrayBuffer): string } };
|
TextDecoder: { new(encoding?: string): { decode(buffer: ArrayBuffer): string } };
|
||||||
@@ -107,8 +105,8 @@ export async function startClient(context: ExtensionContext, newLanguageClient:
|
|||||||
if (e && languageParticipants.hasLanguage(e.document.languageId)) {
|
if (e && languageParticipants.hasLanguage(e.document.languageId)) {
|
||||||
context.globalState.update(promptForLinkedEditingKey, false);
|
context.globalState.update(promptForLinkedEditingKey, false);
|
||||||
activeEditorListener.dispose();
|
activeEditorListener.dispose();
|
||||||
const configure = localize('configureButton', 'Configure');
|
const configure = l10n.t('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 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) {
|
if (res === configure) {
|
||||||
commands.executeCommand('workbench.action.openSettings', SettingIds.linkedEditing);
|
commands.executeCommand('workbench.action.openSettings', SettingIds.linkedEditing);
|
||||||
}
|
}
|
||||||
@@ -299,14 +297,14 @@ async function startClientWithParticipants(languageParticipants: LanguagePartici
|
|||||||
const beginProposal = new CompletionItem('#region', CompletionItemKind.Snippet);
|
const beginProposal = new CompletionItem('#region', CompletionItemKind.Snippet);
|
||||||
beginProposal.range = range;
|
beginProposal.range = range;
|
||||||
beginProposal.insertText = new SnippetString('<!-- #region $1-->');
|
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.filterText = match[2];
|
||||||
beginProposal.sortText = 'za';
|
beginProposal.sortText = 'za';
|
||||||
results.push(beginProposal);
|
results.push(beginProposal);
|
||||||
const endProposal = new CompletionItem('#endregion', CompletionItemKind.Snippet);
|
const endProposal = new CompletionItem('#endregion', CompletionItemKind.Snippet);
|
||||||
endProposal.range = range;
|
endProposal.range = range;
|
||||||
endProposal.insertText = new SnippetString('<!-- #endregion -->');
|
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.filterText = match[2];
|
||||||
endProposal.sortText = 'zb';
|
endProposal.sortText = 'zb';
|
||||||
results.push(endProposal);
|
results.push(endProposal);
|
||||||
@@ -331,7 +329,7 @@ async function startClientWithParticipants(languageParticipants: LanguagePartici
|
|||||||
'</body>',
|
'</body>',
|
||||||
'</html>'].join('\n');
|
'</html>'].join('\n');
|
||||||
snippetProposal.insertText = new SnippetString(content);
|
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.filterText = match2[2];
|
||||||
snippetProposal.sortText = 'za';
|
snippetProposal.sortText = 'za';
|
||||||
results.push(snippetProposal);
|
results.push(snippetProposal);
|
||||||
|
|||||||
@@ -260,7 +260,6 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vscode/extension-telemetry": "0.6.2",
|
"@vscode/extension-telemetry": "0.6.2",
|
||||||
"vscode-languageclient": "^8.1.0-next.1",
|
"vscode-languageclient": "^8.1.0-next.1",
|
||||||
"vscode-nls": "^5.2.0",
|
|
||||||
"vscode-uri": "^3.0.6"
|
"vscode-uri": "^3.0.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
"vscode-html-languageservice": "^5.0.2",
|
"vscode-html-languageservice": "^5.0.2",
|
||||||
"vscode-languageserver": "^8.1.0-next.1",
|
"vscode-languageserver": "^8.1.0-next.1",
|
||||||
"vscode-languageserver-textdocument": "^1.0.7",
|
"vscode-languageserver-textdocument": "^1.0.7",
|
||||||
"vscode-nls": "^5.2.0",
|
|
||||||
"vscode-uri": "^3.0.6"
|
"vscode-uri": "^3.0.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ vscode-nls@^5.2.0:
|
|||||||
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.2.0.tgz#3cb6893dd9bd695244d8a024bdf746eea665cc3f"
|
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.2.0.tgz#3cb6893dd9bd695244d8a024bdf746eea665cc3f"
|
||||||
integrity sha512-RAaHx7B14ZU04EU31pT+rKz2/zSl7xMsfIZuo8pd+KZO6PXtQmpevpq3vxvWNcrGbdmhM/rr5Uw5Mz+NBfhVng==
|
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"
|
version "3.0.6"
|
||||||
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-3.0.6.tgz#5e6e2e1a4170543af30151b561a41f71db1d6f91"
|
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-3.0.6.tgz#5e6e2e1a4170543af30151b561a41f71db1d6f91"
|
||||||
integrity sha512-fmL7V1eiDBFRRnu+gfRWTzyPpNIHJTc4mWnFkwBUmO9U3KPgJAmTx7oxi2bl/Rh6HLdU7+4C9wlj0k2E4AdKFQ==
|
integrity sha512-fmL7V1eiDBFRRnu+gfRWTzyPpNIHJTc4mWnFkwBUmO9U3KPgJAmTx7oxi2bl/Rh6HLdU7+4C9wlj0k2E4AdKFQ==
|
||||||
|
|||||||
@@ -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"
|
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.17.2.tgz#b2c2e7de405ad3d73a883e91989b850170ffc4f2"
|
||||||
integrity sha512-zHhCWatviizPIq9B7Vh9uvrH6x3sK8itC84HkamnBWoDFJtzBf7SWlpLCZUit72b3os45h6RWQNC9xHRDF8dRA==
|
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:
|
vscode-uri@^3.0.6:
|
||||||
version "3.0.6"
|
version "3.0.6"
|
||||||
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-3.0.6.tgz#5e6e2e1a4170543af30151b561a41f71db1d6f91"
|
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-3.0.6.tgz#5e6e2e1a4170543af30151b561a41f71db1d6f91"
|
||||||
|
|||||||
@@ -2,16 +2,13 @@
|
|||||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
* 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[] };
|
export type JSONLanguageStatus = { schemas: string[] };
|
||||||
|
|
||||||
import {
|
import {
|
||||||
workspace, window, languages, commands, ExtensionContext, extensions, Uri, ColorInformation,
|
workspace, window, languages, commands, ExtensionContext, extensions, Uri, ColorInformation,
|
||||||
Diagnostic, StatusBarAlignment, TextEditor, TextDocument, FormattingOptions, CancellationToken, FoldingRange,
|
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';
|
} from 'vscode';
|
||||||
import {
|
import {
|
||||||
LanguageClientOptions, RequestType, NotificationType,
|
LanguageClientOptions, RequestType, NotificationType,
|
||||||
@@ -106,7 +103,7 @@ export interface SchemaRequestService {
|
|||||||
clearCache?(): Promise<string[]>;
|
clearCache?(): Promise<string[]>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const languageServerDescription = localize('jsonserver.name', 'JSON Language Server');
|
export const languageServerDescription = l10n.t('JSON Language Server');
|
||||||
|
|
||||||
let resultLimit = 5000;
|
let resultLimit = 5000;
|
||||||
let jsonFoldingLimit = 5000;
|
let jsonFoldingLimit = 5000;
|
||||||
@@ -121,7 +118,7 @@ export async function startClient(context: ExtensionContext, newLanguageClient:
|
|||||||
const documentSelector = ['json', 'jsonc'];
|
const documentSelector = ['json', 'jsonc'];
|
||||||
|
|
||||||
const schemaResolutionErrorStatusBarItem = window.createStatusBarItem('status.json.resolveError', StatusBarAlignment.Right, 0);
|
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)';
|
schemaResolutionErrorStatusBarItem.text = '$(alert)';
|
||||||
toDispose.push(schemaResolutionErrorStatusBarItem);
|
toDispose.push(schemaResolutionErrorStatusBarItem);
|
||||||
|
|
||||||
@@ -139,7 +136,7 @@ export async function startClient(context: ExtensionContext, newLanguageClient:
|
|||||||
const cachedSchemas = await runtime.schemaRequests.clearCache();
|
const cachedSchemas = await runtime.schemaRequests.clearCache();
|
||||||
await client.sendNotification(SchemaContentChangeNotification.type, cachedSchemas);
|
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
|
// Options to control the language client
|
||||||
@@ -277,7 +274,7 @@ export async function startClient(context: ExtensionContext, newLanguageClient:
|
|||||||
client.onRequest(VSCodeContentRequest.type, (uriPath: string) => {
|
client.onRequest(VSCodeContentRequest.type, (uriPath: string) => {
|
||||||
const uri = Uri.parse(uriPath);
|
const uri = Uri.parse(uriPath);
|
||||||
if (uri.scheme === 'untitled') {
|
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') {
|
if (uri.scheme !== 'http' && uri.scheme !== 'https') {
|
||||||
return workspace.openTextDocument(uri).then(doc => {
|
return workspace.openTextDocument(uri).then(doc => {
|
||||||
@@ -301,7 +298,7 @@ export async function startClient(context: ExtensionContext, newLanguageClient:
|
|||||||
return Promise.reject(new ResponseError(4, e.toString()));
|
return Promise.reject(new ResponseError(4, e.toString()));
|
||||||
});
|
});
|
||||||
} else {
|
} 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)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -417,11 +414,11 @@ export async function startClient(context: ExtensionContext, newLanguageClient:
|
|||||||
function updateSchemaDownloadSetting() {
|
function updateSchemaDownloadSetting() {
|
||||||
schemaDownloadEnabled = workspace.getConfiguration().get(SettingIds.enableSchemaDownload) !== false;
|
schemaDownloadEnabled = workspace.getConfiguration().get(SettingIds.enableSchemaDownload) !== false;
|
||||||
if (schemaDownloadEnabled) {
|
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';
|
schemaResolutionErrorStatusBarItem.command = '_json.retryResolveSchema';
|
||||||
handleRetryResolveSchemaCommand();
|
handleRetryResolveSchemaCommand();
|
||||||
} else {
|
} 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: '' };
|
schemaResolutionErrorStatusBarItem.command = { command: 'workbench.action.openSettings', arguments: [SettingIds.enableSchemaDownload], title: '' };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,14 +6,10 @@
|
|||||||
import {
|
import {
|
||||||
window, languages, Uri, Disposable, commands, QuickPickItem,
|
window, languages, Uri, Disposable, commands, QuickPickItem,
|
||||||
extensions, workspace, Extension, WorkspaceFolder, QuickPickItemKind,
|
extensions, workspace, Extension, WorkspaceFolder, QuickPickItemKind,
|
||||||
ThemeIcon, TextDocument, LanguageStatusSeverity
|
ThemeIcon, TextDocument, LanguageStatusSeverity, l10n
|
||||||
} from 'vscode';
|
} from 'vscode';
|
||||||
import { JSONLanguageStatus, JSONSchemaSettings } from './jsonClient';
|
import { JSONLanguageStatus, JSONSchemaSettings } from './jsonClient';
|
||||||
|
|
||||||
import * as nls from 'vscode-nls';
|
|
||||||
|
|
||||||
const localize = nls.loadMessageBundle();
|
|
||||||
|
|
||||||
type ShowSchemasInput = {
|
type ShowSchemasInput = {
|
||||||
schemas: string[];
|
schemas: string[];
|
||||||
uri: string;
|
uri: string;
|
||||||
@@ -47,9 +43,9 @@ function getExtensionSchemaAssociations() {
|
|||||||
if (association.fullUri === uri) {
|
if (association.fullUri === uri) {
|
||||||
return {
|
return {
|
||||||
label: association.label,
|
label: association.label,
|
||||||
detail: localize('schemaFromextension', 'Configured by extension: {0}', association.extension.id),
|
detail: l10n.t('Configured by extension: {0}', association.extension.id),
|
||||||
uri: Uri.parse(association.fullUri),
|
uri: Uri.parse(association.fullUri),
|
||||||
buttons: [{ iconPath: new ThemeIcon('extensions'), tooltip: localize('openExtension', 'Open Extension') }],
|
buttons: [{ iconPath: new ThemeIcon('extensions'), tooltip: l10n.t('Open Extension') }],
|
||||||
buttonCommands: [() => commands.executeCommand('workbench.extensions.action.showExtensionsWithIds', [[association.extension.id]])]
|
buttonCommands: [() => commands.executeCommand('workbench.extensions.action.showExtensionsWithIds', [[association.extension.id]])]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -101,9 +97,9 @@ function getSettingsSchemaAssociations(uri: string) {
|
|||||||
if (association.fullUri === uri) {
|
if (association.fullUri === uri) {
|
||||||
return {
|
return {
|
||||||
label: association.label,
|
label: association.label,
|
||||||
detail: association.workspaceFolder ? localize('schemaFromFolderSettings', 'Configured in workspace settings') : localize('schemaFromUserSettings', 'Configured in user settings'),
|
detail: association.workspaceFolder ? l10n.t('Configured in workspace settings') : l10n.t('Configured in user settings'),
|
||||||
uri: Uri.parse(association.fullUri),
|
uri: Uri.parse(association.fullUri),
|
||||||
buttons: [{ iconPath: new ThemeIcon('gear'), tooltip: localize('openSettings', 'Open Settings') }],
|
buttons: [{ iconPath: new ThemeIcon('gear'), tooltip: l10n.t('Open Settings') }],
|
||||||
buttonCommands: [() => commands.executeCommand(association.workspaceFolder ? 'workbench.action.openWorkspaceSettingsFile' : 'workbench.action.openSettingsJson', ['json.schemas'])]
|
buttonCommands: [() => commands.executeCommand(association.workspaceFolder ? 'workbench.action.openWorkspaceSettingsFile' : 'workbench.action.openSettingsJson', ['json.schemas'])]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -139,17 +135,17 @@ function showSchemaList(input: ShowSchemasInput) {
|
|||||||
const items: ShowSchemasItem[] = [...extensionEntries, ...settingsEntries, ...otherEntries];
|
const items: ShowSchemasItem[] = [...extensionEntries, ...settingsEntries, ...otherEntries];
|
||||||
if (items.length === 0) {
|
if (items.length === 0) {
|
||||||
items.push({
|
items.push({
|
||||||
label: localize('schema.noSchema', 'No schema configured for this file'),
|
label: l10n.t('No schema configured for this file'),
|
||||||
buttons: [{ iconPath: new ThemeIcon('gear'), tooltip: localize('openSettings', 'Open Settings') }],
|
buttons: [{ iconPath: new ThemeIcon('gear'), tooltip: l10n.t('Open Settings') }],
|
||||||
buttonCommands: [() => commands.executeCommand('workbench.action.openSettingsJson', ['json.schemas'])]
|
buttonCommands: [() => commands.executeCommand('workbench.action.openSettingsJson', ['json.schemas'])]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
items.push({ label: '', kind: QuickPickItemKind.Separator });
|
items.push({ label: '', kind: QuickPickItemKind.Separator });
|
||||||
items.push({ label: localize('schema.showdocs', 'Learn more about JSON schema configuration...'), uri: Uri.parse('https://code.visualstudio.com/docs/languages/json#_json-schemas-and-settings') });
|
items.push({ label: l10n.t('Learn more about JSON schema configuration...'), uri: Uri.parse('https://code.visualstudio.com/docs/languages/json#_json-schemas-and-settings') });
|
||||||
|
|
||||||
const quickPick = window.createQuickPick<ShowSchemasItem>();
|
const quickPick = window.createQuickPick<ShowSchemasItem>();
|
||||||
quickPick.placeholder = items.length ? localize('schemaPicker.placeholder', 'Select the schema to use for {0}', input.uri) : undefined;
|
quickPick.placeholder = items.length ? l10n.t('Select the schema to use for {0}', input.uri) : undefined;
|
||||||
quickPick.items = items;
|
quickPick.items = items;
|
||||||
quickPick.show();
|
quickPick.show();
|
||||||
quickPick.onDidAccept(() => {
|
quickPick.onDidAccept(() => {
|
||||||
@@ -169,7 +165,7 @@ function showSchemaList(input: ShowSchemasInput) {
|
|||||||
|
|
||||||
export function createLanguageStatusItem(documentSelector: string[], statusRequest: (uri: string) => Promise<JSONLanguageStatus>): Disposable {
|
export function createLanguageStatusItem(documentSelector: string[], statusRequest: (uri: string) => Promise<JSONLanguageStatus>): Disposable {
|
||||||
const statusItem = languages.createLanguageStatusItem('json.projectStatus', documentSelector);
|
const statusItem = languages.createLanguageStatusItem('json.projectStatus', documentSelector);
|
||||||
statusItem.name = localize('statusItem.name', "JSON Validation Status");
|
statusItem.name = l10n.t('JSON Validation Status');
|
||||||
statusItem.severity = LanguageStatusSeverity.Information;
|
statusItem.severity = LanguageStatusSeverity.Information;
|
||||||
|
|
||||||
const showSchemasCommand = commands.registerCommand('_json.showAssociatedSchemaList', showSchemaList);
|
const showSchemasCommand = commands.registerCommand('_json.showAssociatedSchemaList', showSchemaList);
|
||||||
@@ -183,33 +179,33 @@ export function createLanguageStatusItem(documentSelector: string[], statusReque
|
|||||||
if (document) {
|
if (document) {
|
||||||
try {
|
try {
|
||||||
statusItem.text = '$(loading~spin)';
|
statusItem.text = '$(loading~spin)';
|
||||||
statusItem.detail = localize('pending.detail', 'Loading JSON info');
|
statusItem.detail = l10n.t('Loading JSON info');
|
||||||
statusItem.command = undefined;
|
statusItem.command = undefined;
|
||||||
|
|
||||||
const schemas = (await statusRequest(document.uri.toString())).schemas;
|
const schemas = (await statusRequest(document.uri.toString())).schemas;
|
||||||
statusItem.detail = undefined;
|
statusItem.detail = undefined;
|
||||||
if (schemas.length === 0) {
|
if (schemas.length === 0) {
|
||||||
statusItem.text = localize('status.noSchema.short', "No Schema Validation");
|
statusItem.text = l10n.t('No Schema Validation');
|
||||||
statusItem.detail = localize('status.noSchema', 'no JSON schema configured');
|
statusItem.detail = l10n.t('no JSON schema configured');
|
||||||
} else if (schemas.length === 1) {
|
} else if (schemas.length === 1) {
|
||||||
statusItem.text = localize('status.withSchema.short', "Schema Validated");
|
statusItem.text = l10n.t('Schema Validated');
|
||||||
statusItem.detail = localize('status.singleSchema', 'JSON schema configured');
|
statusItem.detail = l10n.t('JSON schema configured');
|
||||||
} else {
|
} else {
|
||||||
statusItem.text = localize('status.withSchemas.short', "Schema Validated");
|
statusItem.text = l10n.t('Schema Validated');
|
||||||
statusItem.detail = localize('status.multipleSchema', 'multiple JSON schemas configured');
|
statusItem.detail = l10n.t('multiple JSON schemas configured');
|
||||||
}
|
}
|
||||||
statusItem.command = {
|
statusItem.command = {
|
||||||
command: '_json.showAssociatedSchemaList',
|
command: '_json.showAssociatedSchemaList',
|
||||||
title: localize('status.openSchemasLink', 'Show Schemas'),
|
title: l10n.t('Show Schemas'),
|
||||||
arguments: [{ schemas, uri: document.uri.toString() } as ShowSchemasInput]
|
arguments: [{ schemas, uri: document.uri.toString() } as ShowSchemasInput]
|
||||||
};
|
};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
statusItem.text = localize('status.error1', 'Unable to compute used schemas: {0}', e.message);
|
statusItem.text = l10n.t('Unable to compute used schemas: {0}', e.message);
|
||||||
statusItem.detail = undefined;
|
statusItem.detail = undefined;
|
||||||
statusItem.command = undefined;
|
statusItem.command = undefined;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
statusItem.text = localize('status.error2', 'Unable to compute used schemas: No document');
|
statusItem.text = l10n.t('Unable to compute used schemas: No document');
|
||||||
statusItem.detail = undefined;
|
statusItem.detail = undefined;
|
||||||
statusItem.command = undefined;
|
statusItem.command = undefined;
|
||||||
}
|
}
|
||||||
@@ -270,34 +266,24 @@ export function createLimitStatusItem(newItem: (limit: number) => Disposable) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const openSettingsCommand = 'workbench.action.openSettings';
|
const openSettingsCommand = 'workbench.action.openSettings';
|
||||||
const configureSettingsLabel = localize('status.button.configure', "Configure");
|
const configureSettingsLabel = l10n.t('Configure');
|
||||||
|
|
||||||
export function createFoldingRangeLimitItem(documentSelector: string[], settingId: string, limit: number): Disposable {
|
|
||||||
const statusItem = languages.createLanguageStatusItem('json.foldingRangesStatus', documentSelector);
|
|
||||||
statusItem.name = localize('foldingRangesStatusItem.name', "JSON Folding Status");
|
|
||||||
statusItem.severity = LanguageStatusSeverity.Warning;
|
|
||||||
statusItem.text = localize('status.limitedFoldingRanges.short', "Folding Ranges Limited");
|
|
||||||
statusItem.detail = localize('status.limitedFoldingRanges.details', 'only {0} folding ranges shown', limit);
|
|
||||||
statusItem.command = { command: openSettingsCommand, arguments: [settingId], title: configureSettingsLabel };
|
|
||||||
return Disposable.from(statusItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createDocumentSymbolsLimitItem(documentSelector: string[], settingId: string, limit: number): Disposable {
|
export function createDocumentSymbolsLimitItem(documentSelector: string[], settingId: string, limit: number): Disposable {
|
||||||
const statusItem = languages.createLanguageStatusItem('json.documentSymbolsStatus', documentSelector);
|
const statusItem = languages.createLanguageStatusItem('json.documentSymbolsStatus', documentSelector);
|
||||||
statusItem.name = localize('documentSymbolsStatusItem.name', "JSON Outline Status");
|
statusItem.name = l10n.t('JSON Outline Status');
|
||||||
statusItem.severity = LanguageStatusSeverity.Warning;
|
statusItem.severity = LanguageStatusSeverity.Warning;
|
||||||
statusItem.text = localize('status.limitedDocumentSymbols.short', "Outline Limited");
|
statusItem.text = l10n.t('Outline Limited');
|
||||||
statusItem.detail = localize('status.limitedDocumentSymbols.details', 'only {0} document symbols shown', limit);
|
statusItem.detail = l10n.t('only {0} document symbols shown', limit);
|
||||||
statusItem.command = { command: openSettingsCommand, arguments: [settingId], title: configureSettingsLabel };
|
statusItem.command = { command: openSettingsCommand, arguments: [settingId], title: configureSettingsLabel };
|
||||||
return Disposable.from(statusItem);
|
return Disposable.from(statusItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createDocumentColorsLimitItem(documentSelector: string[], settingId: string, limit: number): Disposable {
|
export function createDocumentColorsLimitItem(documentSelector: string[], settingId: string, limit: number): Disposable {
|
||||||
const statusItem = languages.createLanguageStatusItem('json.documentColorsStatus', documentSelector);
|
const statusItem = languages.createLanguageStatusItem('json.documentColorsStatus', documentSelector);
|
||||||
statusItem.name = localize('documentColorsStatusItem.name', "JSON Color Symbol Status");
|
statusItem.name = l10n.t('JSON Color Symbol Status');
|
||||||
statusItem.severity = LanguageStatusSeverity.Warning;
|
statusItem.severity = LanguageStatusSeverity.Warning;
|
||||||
statusItem.text = localize('status.limitedDocumentColors.short', "Color Symbols Limited");
|
statusItem.text = l10n.t('Color Symbols Limited');
|
||||||
statusItem.detail = localize('status.limitedDocumentColors.details', 'only {0} color decorators shown', limit);
|
statusItem.detail = l10n.t('only {0} color decorators shown', limit);
|
||||||
statusItem.command = { command: openSettingsCommand, arguments: [settingId], title: configureSettingsLabel };
|
statusItem.command = { command: openSettingsCommand, arguments: [settingId], title: configureSettingsLabel };
|
||||||
return Disposable.from(statusItem);
|
return Disposable.from(statusItem);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,8 +155,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vscode/extension-telemetry": "0.6.2",
|
"@vscode/extension-telemetry": "0.6.2",
|
||||||
"request-light": "^0.5.8",
|
"request-light": "^0.5.8",
|
||||||
"vscode-languageclient": "^8.1.0-next.1",
|
"vscode-languageclient": "^8.1.0-next.1"
|
||||||
"vscode-nls": "^5.2.0"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "16.x"
|
"@types/node": "16.x"
|
||||||
|
|||||||
@@ -116,11 +116,6 @@ vscode-languageserver-types@3.17.2:
|
|||||||
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.17.2.tgz#b2c2e7de405ad3d73a883e91989b850170ffc4f2"
|
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.17.2.tgz#b2c2e7de405ad3d73a883e91989b850170ffc4f2"
|
||||||
integrity sha512-zHhCWatviizPIq9B7Vh9uvrH6x3sK8itC84HkamnBWoDFJtzBf7SWlpLCZUit72b3os45h6RWQNC9xHRDF8dRA==
|
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==
|
|
||||||
|
|
||||||
yallist@^4.0.0:
|
yallist@^4.0.0:
|
||||||
version "4.0.0"
|
version "4.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
|
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
|
||||||
|
|||||||
Reference in New Issue
Block a user