mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
add nls module and externalize human readable strings
This commit is contained in:
parent
a86c6ffae5
commit
bbf389005c
|
@ -406,6 +406,9 @@
|
||||||
"compile": "npx gulp compile-extension:references-view",
|
"compile": "npx gulp compile-extension:references-view",
|
||||||
"watch": "npx gulp watch-extension:references-view"
|
"watch": "npx gulp watch-extension:references-view"
|
||||||
},
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"vscode-nls": "^5.0.0"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "16.x"
|
"@types/node": "16.x"
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import { SymbolItemDragAndDrop, SymbolItemEditorHighlights, SymbolItemNavigation, SymbolTreeInput } from '../references-view';
|
import { SymbolItemDragAndDrop, SymbolItemEditorHighlights, SymbolItemNavigation, SymbolTreeInput } from '../references-view';
|
||||||
import { asResourceUrl, del, getThemeIcon, tail } from '../utils';
|
import { asResourceUrl, del, getThemeIcon, tail } from '../utils';
|
||||||
|
import * as nls from 'vscode-nls';
|
||||||
|
const localize = nls.loadMessageBundle();
|
||||||
|
|
||||||
export class CallsTreeInput implements SymbolTreeInput<CallItem> {
|
export class CallsTreeInput implements SymbolTreeInput<CallItem> {
|
||||||
|
|
||||||
|
@ -18,8 +19,8 @@ export class CallsTreeInput implements SymbolTreeInput<CallItem> {
|
||||||
readonly direction: CallsDirection,
|
readonly direction: CallsDirection,
|
||||||
) {
|
) {
|
||||||
this.title = direction === CallsDirection.Incoming
|
this.title = direction === CallsDirection.Incoming
|
||||||
? 'Callers Of'
|
? localize('title.callers', 'Callers Of')
|
||||||
: 'Calls From';
|
: localize('title.calls', 'Calls From');
|
||||||
}
|
}
|
||||||
|
|
||||||
async resolve() {
|
async resolve() {
|
||||||
|
@ -34,7 +35,7 @@ export class CallsTreeInput implements SymbolTreeInput<CallItem> {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
provider,
|
provider,
|
||||||
get message() { return model.roots.length === 0 ? 'No results.' : undefined; },
|
get message() { return model.roots.length === 0 ? localize('noresult', 'No results.') : undefined; },
|
||||||
navigation: model,
|
navigation: model,
|
||||||
highlights: model,
|
highlights: model,
|
||||||
dnd: model,
|
dnd: model,
|
||||||
|
@ -183,7 +184,7 @@ class CallItemDataProvider implements vscode.TreeDataProvider<CallItem> {
|
||||||
item.iconPath = getThemeIcon(element.item.kind);
|
item.iconPath = getThemeIcon(element.item.kind);
|
||||||
item.command = {
|
item.command = {
|
||||||
command: 'vscode.open',
|
command: 'vscode.open',
|
||||||
title: 'Open Call',
|
title: localize('open', 'Open Call'),
|
||||||
arguments: [
|
arguments: [
|
||||||
element.item.uri,
|
element.item.uri,
|
||||||
<vscode.TextDocumentShowOptions>{ selection: element.item.selectionRange.with({ end: element.item.selectionRange.start }) }
|
<vscode.TextDocumentShowOptions>{ selection: element.item.selectionRange.with({ end: element.item.selectionRange.start }) }
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import { SymbolsTree } from '../tree';
|
import { SymbolsTree } from '../tree';
|
||||||
import { FileItem, ReferenceItem, ReferencesModel, ReferencesTreeInput } from './model';
|
import { FileItem, ReferenceItem, ReferencesModel, ReferencesTreeInput } from './model';
|
||||||
|
import * as nls from 'vscode-nls';
|
||||||
|
const localize = nls.loadMessageBundle();
|
||||||
|
|
||||||
export function register(tree: SymbolsTree, context: vscode.ExtensionContext): void {
|
export function register(tree: SymbolsTree, context: vscode.ExtensionContext): void {
|
||||||
|
|
||||||
|
@ -43,7 +45,7 @@ export function register(tree: SymbolsTree, context: vscode.ExtensionContext): v
|
||||||
|
|
||||||
if (value === 'view') {
|
if (value === 'view') {
|
||||||
showReferencesDisposable = vscode.commands.registerCommand('editor.action.showReferences', async (uri: vscode.Uri, position: vscode.Position, locations: vscode.Location[]) => {
|
showReferencesDisposable = vscode.commands.registerCommand('editor.action.showReferences', async (uri: vscode.Uri, position: vscode.Position, locations: vscode.Location[]) => {
|
||||||
const input = new ReferencesTreeInput('References', new vscode.Location(uri, position), 'vscode.executeReferenceProvider', locations);
|
const input = new ReferencesTreeInput(localize('title', 'References'), new vscode.Location(uri, position), 'vscode.executeReferenceProvider', locations);
|
||||||
tree.setInput(input);
|
tree.setInput(input);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import { SymbolItemDragAndDrop, SymbolItemEditorHighlights, SymbolItemNavigation, SymbolTreeInput, SymbolTreeModel } from '../references-view';
|
import { SymbolItemDragAndDrop, SymbolItemEditorHighlights, SymbolItemNavigation, SymbolTreeInput, SymbolTreeModel } from '../references-view';
|
||||||
import { asResourceUrl, del, getPreviewChunks, tail } from '../utils';
|
import { asResourceUrl, del, getPreviewChunks, tail } from '../utils';
|
||||||
|
import * as nls from 'vscode-nls';
|
||||||
|
const localize = nls.loadMessageBundle();
|
||||||
|
|
||||||
export class ReferencesTreeInput implements SymbolTreeInput<FileItem | ReferenceItem> {
|
export class ReferencesTreeInput implements SymbolTreeInput<FileItem | ReferenceItem> {
|
||||||
|
|
||||||
|
@ -110,18 +112,18 @@ export class ReferencesModel implements SymbolItemNavigation<FileItem | Referenc
|
||||||
|
|
||||||
get message() {
|
get message() {
|
||||||
if (this.items.length === 0) {
|
if (this.items.length === 0) {
|
||||||
return 'No results.';
|
return localize('noresult', 'No results.');
|
||||||
}
|
}
|
||||||
const total = this.items.reduce((prev, cur) => prev + cur.references.length, 0);
|
const total = this.items.reduce((prev, cur) => prev + cur.references.length, 0);
|
||||||
const files = this.items.length;
|
const files = this.items.length;
|
||||||
if (total === 1 && files === 1) {
|
if (total === 1 && files === 1) {
|
||||||
return `${total} result in ${files} file`;
|
return localize('result.1', '{0} result in {1} file', total, files);
|
||||||
} else if (total === 1) {
|
} else if (total === 1) {
|
||||||
return `${total} result in ${files} files`;
|
return localize('result.1n', '{0} result in {1} files', total, files);
|
||||||
} else if (files === 1) {
|
} else if (files === 1) {
|
||||||
return `${total} results in ${files} file`;
|
return localize('result.n1', '{0} results in {1} file', total, files);
|
||||||
} else {
|
} else {
|
||||||
return `${total} results in ${files} files`;
|
return localize('result.nm', '{0} results in {1} files', total, files);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,7 +299,7 @@ class ReferencesTreeDataProvider implements vscode.TreeDataProvider<FileItem | R
|
||||||
result.contextValue = 'reference-item';
|
result.contextValue = 'reference-item';
|
||||||
result.command = {
|
result.command = {
|
||||||
command: 'vscode.open',
|
command: 'vscode.open',
|
||||||
title: 'Open Reference',
|
title: localize('open', 'Open Reference'),
|
||||||
arguments: [
|
arguments: [
|
||||||
element.location.uri,
|
element.location.uri,
|
||||||
<vscode.TextDocumentShowOptions>{ selection: range.with({ end: range.start }) }
|
<vscode.TextDocumentShowOptions>{ selection: range.with({ end: range.start }) }
|
||||||
|
|
|
@ -8,6 +8,9 @@ import { EditorHighlights } from './highlights';
|
||||||
import { Navigation } from './navigation';
|
import { Navigation } from './navigation';
|
||||||
import { SymbolItemDragAndDrop, SymbolTreeInput } from './references-view';
|
import { SymbolItemDragAndDrop, SymbolTreeInput } from './references-view';
|
||||||
import { ContextKey, isValidRequestPosition, WordAnchor } from './utils';
|
import { ContextKey, isValidRequestPosition, WordAnchor } from './utils';
|
||||||
|
import * as nls from 'vscode-nls';
|
||||||
|
const localize = nls.loadMessageBundle();
|
||||||
|
|
||||||
|
|
||||||
export class SymbolsTree {
|
export class SymbolsTree {
|
||||||
|
|
||||||
|
@ -120,8 +123,10 @@ export class SymbolsTree {
|
||||||
this._input = undefined;
|
this._input = undefined;
|
||||||
this._ctxHasResult.set(false);
|
this._ctxHasResult.set(false);
|
||||||
this._ctxInputSource.reset();
|
this._ctxInputSource.reset();
|
||||||
this._tree.title = 'References';
|
this._tree.title = localize('title', 'References');
|
||||||
this._tree.message = this._history.size === 0 ? 'No results.' : 'No results. Try running a previous search again:';
|
this._tree.message = this._history.size === 0
|
||||||
|
? localize('noresult', 'No results.')
|
||||||
|
: localize('noresult2', 'No results. Try running a previous search again:');
|
||||||
this._provider.update(Promise.resolve(this._history));
|
this._provider.update(Promise.resolve(this._history));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -278,7 +283,7 @@ class TreeInputHistory implements vscode.TreeDataProvider<HistoryItem>{
|
||||||
description: item.description,
|
description: item.description,
|
||||||
item
|
item
|
||||||
});
|
});
|
||||||
const pick = await vscode.window.showQuickPick(picks, { placeHolder: 'Select previous reference search' });
|
const pick = await vscode.window.showQuickPick(picks, { placeHolder: localize('placeholder', 'Select previous reference search') });
|
||||||
if (pick) {
|
if (pick) {
|
||||||
this._reRunHistoryItem(pick.item);
|
this._reRunHistoryItem(pick.item);
|
||||||
}
|
}
|
||||||
|
@ -333,7 +338,7 @@ class TreeInputHistory implements vscode.TreeDataProvider<HistoryItem>{
|
||||||
getTreeItem(item: HistoryItem): vscode.TreeItem {
|
getTreeItem(item: HistoryItem): vscode.TreeItem {
|
||||||
const result = new vscode.TreeItem(item.word);
|
const result = new vscode.TreeItem(item.word);
|
||||||
result.description = item.description;
|
result.description = item.description;
|
||||||
result.command = { command: '_references-view.showHistoryItem', arguments: [item], title: 'Rerun' };
|
result.command = { command: '_references-view.showHistoryItem', arguments: [item], title: localize('title.rerun', 'Rerun') };
|
||||||
result.collapsibleState = vscode.TreeItemCollapsibleState.None;
|
result.collapsibleState = vscode.TreeItemCollapsibleState.None;
|
||||||
result.contextValue = 'history-item';
|
result.contextValue = 'history-item';
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import { SymbolItemDragAndDrop, SymbolItemEditorHighlights, SymbolItemNavigation, SymbolTreeInput } from '../references-view';
|
import { SymbolItemDragAndDrop, SymbolItemEditorHighlights, SymbolItemNavigation, SymbolTreeInput } from '../references-view';
|
||||||
import { asResourceUrl, del, getThemeIcon, tail } from '../utils';
|
import { asResourceUrl, del, getThemeIcon, tail } from '../utils';
|
||||||
|
import * as nls from 'vscode-nls';
|
||||||
|
const localize = nls.loadMessageBundle();
|
||||||
|
|
||||||
export class TypesTreeInput implements SymbolTreeInput<TypeItem> {
|
export class TypesTreeInput implements SymbolTreeInput<TypeItem> {
|
||||||
|
|
||||||
|
@ -18,8 +19,8 @@ export class TypesTreeInput implements SymbolTreeInput<TypeItem> {
|
||||||
readonly direction: TypeHierarchyDirection,
|
readonly direction: TypeHierarchyDirection,
|
||||||
) {
|
) {
|
||||||
this.title = direction === TypeHierarchyDirection.Supertypes
|
this.title = direction === TypeHierarchyDirection.Supertypes
|
||||||
? 'Supertypes Of'
|
? localize('title.sup', 'Supertypes Of')
|
||||||
: 'Subtypes Of';
|
: localize('title.sub', 'Subtypes Of');
|
||||||
}
|
}
|
||||||
|
|
||||||
async resolve() {
|
async resolve() {
|
||||||
|
@ -34,7 +35,7 @@ export class TypesTreeInput implements SymbolTreeInput<TypeItem> {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
provider,
|
provider,
|
||||||
get message() { return model.roots.length === 0 ? 'No results.' : undefined; },
|
get message() { return model.roots.length === 0 ? localize('noresult', 'No results.') : undefined; },
|
||||||
navigation: model,
|
navigation: model,
|
||||||
highlights: model,
|
highlights: model,
|
||||||
dnd: model,
|
dnd: model,
|
||||||
|
@ -175,7 +176,7 @@ class TypeItemDataProvider implements vscode.TreeDataProvider<TypeItem> {
|
||||||
item.iconPath = getThemeIcon(element.item.kind);
|
item.iconPath = getThemeIcon(element.item.kind);
|
||||||
item.command = {
|
item.command = {
|
||||||
command: 'vscode.open',
|
command: 'vscode.open',
|
||||||
title: 'Open Type',
|
title: localize('title.openType', 'Open Type'),
|
||||||
arguments: [
|
arguments: [
|
||||||
element.item.uri,
|
element.item.uri,
|
||||||
<vscode.TextDocumentShowOptions>{ selection: element.item.selectionRange.with({ end: element.item.selectionRange.start }) }
|
<vscode.TextDocumentShowOptions>{ selection: element.item.selectionRange.with({ end: element.item.selectionRange.start }) }
|
||||||
|
|
|
@ -6,3 +6,8 @@
|
||||||
version "16.11.33"
|
version "16.11.33"
|
||||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.33.tgz#566713b1b626f781c5c58fe3531307283e00720c"
|
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.33.tgz#566713b1b626f781c5c58fe3531307283e00720c"
|
||||||
integrity sha512-0PJ0vg+JyU0MIan58IOIFRtSvsb7Ri+7Wltx2qAg94eMOrpg4+uuP3aUHCpxXc1i0jCXiC+zIamSZh3l9AbcQA==
|
integrity sha512-0PJ0vg+JyU0MIan58IOIFRtSvsb7Ri+7Wltx2qAg94eMOrpg4+uuP3aUHCpxXc1i0jCXiC+zIamSZh3l9AbcQA==
|
||||||
|
|
||||||
|
vscode-nls@^5.0.0:
|
||||||
|
version "5.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.0.1.tgz#ba23fc4d4420d25e7f886c8e83cbdcec47aa48b2"
|
||||||
|
integrity sha512-hHQV6iig+M21lTdItKPkJAaWrxALQb/nqpVffakO4knJOh3DrU2SXOMzUzNgo1eADPzu3qSsJY1weCzvR52q9A==
|
||||||
|
|
Loading…
Reference in a new issue