mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 19:18:59 +01: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
@@ -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,
|
||||
@@ -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;
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
@@ -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 => {
|
||||
@@ -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)));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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: '' };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,14 +6,10 @@
|
||||
import {
|
||||
window, languages, Uri, Disposable, commands, QuickPickItem,
|
||||
extensions, workspace, Extension, WorkspaceFolder, QuickPickItemKind,
|
||||
ThemeIcon, TextDocument, LanguageStatusSeverity
|
||||
ThemeIcon, TextDocument, LanguageStatusSeverity, l10n
|
||||
} from 'vscode';
|
||||
import { JSONLanguageStatus, JSONSchemaSettings } from './jsonClient';
|
||||
|
||||
import * as nls from 'vscode-nls';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
type ShowSchemasInput = {
|
||||
schemas: string[];
|
||||
uri: string;
|
||||
@@ -47,9 +43,9 @@ function getExtensionSchemaAssociations() {
|
||||
if (association.fullUri === uri) {
|
||||
return {
|
||||
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),
|
||||
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]])]
|
||||
};
|
||||
}
|
||||
@@ -101,9 +97,9 @@ function getSettingsSchemaAssociations(uri: string) {
|
||||
if (association.fullUri === uri) {
|
||||
return {
|
||||
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),
|
||||
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'])]
|
||||
};
|
||||
}
|
||||
@@ -139,17 +135,17 @@ function showSchemaList(input: ShowSchemasInput) {
|
||||
const items: ShowSchemasItem[] = [...extensionEntries, ...settingsEntries, ...otherEntries];
|
||||
if (items.length === 0) {
|
||||
items.push({
|
||||
label: localize('schema.noSchema', 'No schema configured for this file'),
|
||||
buttons: [{ iconPath: new ThemeIcon('gear'), tooltip: localize('openSettings', 'Open Settings') }],
|
||||
label: l10n.t('No schema configured for this file'),
|
||||
buttons: [{ iconPath: new ThemeIcon('gear'), tooltip: l10n.t('Open Settings') }],
|
||||
buttonCommands: [() => commands.executeCommand('workbench.action.openSettingsJson', ['json.schemas'])]
|
||||
});
|
||||
}
|
||||
|
||||
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>();
|
||||
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.show();
|
||||
quickPick.onDidAccept(() => {
|
||||
@@ -169,7 +165,7 @@ function showSchemaList(input: ShowSchemasInput) {
|
||||
|
||||
export function createLanguageStatusItem(documentSelector: string[], statusRequest: (uri: string) => Promise<JSONLanguageStatus>): Disposable {
|
||||
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;
|
||||
|
||||
const showSchemasCommand = commands.registerCommand('_json.showAssociatedSchemaList', showSchemaList);
|
||||
@@ -183,33 +179,33 @@ export function createLanguageStatusItem(documentSelector: string[], statusReque
|
||||
if (document) {
|
||||
try {
|
||||
statusItem.text = '$(loading~spin)';
|
||||
statusItem.detail = localize('pending.detail', 'Loading JSON info');
|
||||
statusItem.detail = l10n.t('Loading JSON info');
|
||||
statusItem.command = undefined;
|
||||
|
||||
const schemas = (await statusRequest(document.uri.toString())).schemas;
|
||||
statusItem.detail = undefined;
|
||||
if (schemas.length === 0) {
|
||||
statusItem.text = localize('status.noSchema.short', "No Schema Validation");
|
||||
statusItem.detail = localize('status.noSchema', 'no JSON schema configured');
|
||||
statusItem.text = l10n.t('No Schema Validation');
|
||||
statusItem.detail = l10n.t('no JSON schema configured');
|
||||
} else if (schemas.length === 1) {
|
||||
statusItem.text = localize('status.withSchema.short', "Schema Validated");
|
||||
statusItem.detail = localize('status.singleSchema', 'JSON schema configured');
|
||||
statusItem.text = l10n.t('Schema Validated');
|
||||
statusItem.detail = l10n.t('JSON schema configured');
|
||||
} else {
|
||||
statusItem.text = localize('status.withSchemas.short', "Schema Validated");
|
||||
statusItem.detail = localize('status.multipleSchema', 'multiple JSON schemas configured');
|
||||
statusItem.text = l10n.t('Schema Validated');
|
||||
statusItem.detail = l10n.t('multiple JSON schemas configured');
|
||||
}
|
||||
statusItem.command = {
|
||||
command: '_json.showAssociatedSchemaList',
|
||||
title: localize('status.openSchemasLink', 'Show Schemas'),
|
||||
title: l10n.t('Show Schemas'),
|
||||
arguments: [{ schemas, uri: document.uri.toString() } as ShowSchemasInput]
|
||||
};
|
||||
} 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.command = undefined;
|
||||
}
|
||||
} 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.command = undefined;
|
||||
}
|
||||
@@ -270,34 +266,24 @@ export function createLimitStatusItem(newItem: (limit: number) => Disposable) {
|
||||
}
|
||||
|
||||
const openSettingsCommand = 'workbench.action.openSettings';
|
||||
const configureSettingsLabel = localize('status.button.configure', "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);
|
||||
}
|
||||
const configureSettingsLabel = l10n.t('Configure');
|
||||
|
||||
export function createDocumentSymbolsLimitItem(documentSelector: string[], settingId: string, limit: number): Disposable {
|
||||
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.text = localize('status.limitedDocumentSymbols.short', "Outline Limited");
|
||||
statusItem.detail = localize('status.limitedDocumentSymbols.details', 'only {0} document symbols shown', limit);
|
||||
statusItem.text = l10n.t('Outline Limited');
|
||||
statusItem.detail = l10n.t('only {0} document symbols shown', limit);
|
||||
statusItem.command = { command: openSettingsCommand, arguments: [settingId], title: configureSettingsLabel };
|
||||
return Disposable.from(statusItem);
|
||||
}
|
||||
|
||||
export function createDocumentColorsLimitItem(documentSelector: string[], settingId: string, limit: number): Disposable {
|
||||
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.text = localize('status.limitedDocumentColors.short', "Color Symbols Limited");
|
||||
statusItem.detail = localize('status.limitedDocumentColors.details', 'only {0} color decorators shown', limit);
|
||||
statusItem.text = l10n.t('Color Symbols Limited');
|
||||
statusItem.detail = l10n.t('only {0} color decorators shown', limit);
|
||||
statusItem.command = { command: openSettingsCommand, arguments: [settingId], title: configureSettingsLabel };
|
||||
return Disposable.from(statusItem);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user