mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-21 02:39:14 +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
@@ -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