diff --git a/extensions/references-view/package.json b/extensions/references-view/package.json index f78334afb28..f5c0a910f1e 100644 --- a/extensions/references-view/package.json +++ b/extensions/references-view/package.json @@ -406,6 +406,9 @@ "compile": "npx gulp compile-extension:references-view", "watch": "npx gulp watch-extension:references-view" }, + "dependencies": { + "vscode-nls": "^5.0.0" + }, "devDependencies": { "@types/node": "16.x" } diff --git a/extensions/references-view/src/calls/model.ts b/extensions/references-view/src/calls/model.ts index 7df19f9931b..0efa35f4e02 100644 --- a/extensions/references-view/src/calls/model.ts +++ b/extensions/references-view/src/calls/model.ts @@ -6,7 +6,8 @@ import * as vscode from 'vscode'; import { SymbolItemDragAndDrop, SymbolItemEditorHighlights, SymbolItemNavigation, SymbolTreeInput } from '../references-view'; import { asResourceUrl, del, getThemeIcon, tail } from '../utils'; - +import * as nls from 'vscode-nls'; +const localize = nls.loadMessageBundle(); export class CallsTreeInput implements SymbolTreeInput { @@ -18,8 +19,8 @@ export class CallsTreeInput implements SymbolTreeInput { readonly direction: CallsDirection, ) { this.title = direction === CallsDirection.Incoming - ? 'Callers Of' - : 'Calls From'; + ? localize('title.callers', 'Callers Of') + : localize('title.calls', 'Calls From'); } async resolve() { @@ -34,7 +35,7 @@ export class CallsTreeInput implements SymbolTreeInput { return { 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, highlights: model, dnd: model, @@ -183,7 +184,7 @@ class CallItemDataProvider implements vscode.TreeDataProvider { item.iconPath = getThemeIcon(element.item.kind); item.command = { command: 'vscode.open', - title: 'Open Call', + title: localize('open', 'Open Call'), arguments: [ element.item.uri, { selection: element.item.selectionRange.with({ end: element.item.selectionRange.start }) } diff --git a/extensions/references-view/src/references/index.ts b/extensions/references-view/src/references/index.ts index f0a8fb85c3c..e54740dc66a 100644 --- a/extensions/references-view/src/references/index.ts +++ b/extensions/references-view/src/references/index.ts @@ -6,6 +6,8 @@ import * as vscode from 'vscode'; import { SymbolsTree } from '../tree'; 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 { @@ -43,7 +45,7 @@ export function register(tree: SymbolsTree, context: vscode.ExtensionContext): v if (value === 'view') { 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); }); } diff --git a/extensions/references-view/src/references/model.ts b/extensions/references-view/src/references/model.ts index 2c0edf5f453..9814f3ec32f 100644 --- a/extensions/references-view/src/references/model.ts +++ b/extensions/references-view/src/references/model.ts @@ -6,6 +6,8 @@ import * as vscode from 'vscode'; import { SymbolItemDragAndDrop, SymbolItemEditorHighlights, SymbolItemNavigation, SymbolTreeInput, SymbolTreeModel } from '../references-view'; import { asResourceUrl, del, getPreviewChunks, tail } from '../utils'; +import * as nls from 'vscode-nls'; +const localize = nls.loadMessageBundle(); export class ReferencesTreeInput implements SymbolTreeInput { @@ -110,18 +112,18 @@ export class ReferencesModel implements SymbolItemNavigation prev + cur.references.length, 0); const files = this.items.length; 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) { - return `${total} result in ${files} files`; + return localize('result.1n', '{0} result in {1} files', total, files); } else if (files === 1) { - return `${total} results in ${files} file`; + return localize('result.n1', '{0} results in {1} file', total, files); } 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{ selection: range.with({ end: range.start }) } diff --git a/extensions/references-view/src/tree.ts b/extensions/references-view/src/tree.ts index 56a3dc69ffe..8eb533cc5da 100644 --- a/extensions/references-view/src/tree.ts +++ b/extensions/references-view/src/tree.ts @@ -8,6 +8,9 @@ import { EditorHighlights } from './highlights'; import { Navigation } from './navigation'; import { SymbolItemDragAndDrop, SymbolTreeInput } from './references-view'; import { ContextKey, isValidRequestPosition, WordAnchor } from './utils'; +import * as nls from 'vscode-nls'; +const localize = nls.loadMessageBundle(); + export class SymbolsTree { @@ -120,8 +123,10 @@ export class SymbolsTree { this._input = undefined; this._ctxHasResult.set(false); this._ctxInputSource.reset(); - this._tree.title = 'References'; - this._tree.message = this._history.size === 0 ? 'No results.' : 'No results. Try running a previous search again:'; + this._tree.title = localize('title', 'References'); + 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)); } } @@ -278,7 +283,7 @@ class TreeInputHistory implements vscode.TreeDataProvider{ description: item.description, 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) { this._reRunHistoryItem(pick.item); } @@ -333,7 +338,7 @@ class TreeInputHistory implements vscode.TreeDataProvider{ getTreeItem(item: HistoryItem): vscode.TreeItem { const result = new vscode.TreeItem(item.word); 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.contextValue = 'history-item'; return result; diff --git a/extensions/references-view/src/types/model.ts b/extensions/references-view/src/types/model.ts index 964a70fe7b1..31bbe9403e3 100644 --- a/extensions/references-view/src/types/model.ts +++ b/extensions/references-view/src/types/model.ts @@ -6,7 +6,8 @@ import * as vscode from 'vscode'; import { SymbolItemDragAndDrop, SymbolItemEditorHighlights, SymbolItemNavigation, SymbolTreeInput } from '../references-view'; import { asResourceUrl, del, getThemeIcon, tail } from '../utils'; - +import * as nls from 'vscode-nls'; +const localize = nls.loadMessageBundle(); export class TypesTreeInput implements SymbolTreeInput { @@ -18,8 +19,8 @@ export class TypesTreeInput implements SymbolTreeInput { readonly direction: TypeHierarchyDirection, ) { this.title = direction === TypeHierarchyDirection.Supertypes - ? 'Supertypes Of' - : 'Subtypes Of'; + ? localize('title.sup', 'Supertypes Of') + : localize('title.sub', 'Subtypes Of'); } async resolve() { @@ -34,7 +35,7 @@ export class TypesTreeInput implements SymbolTreeInput { return { 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, highlights: model, dnd: model, @@ -175,7 +176,7 @@ class TypeItemDataProvider implements vscode.TreeDataProvider { item.iconPath = getThemeIcon(element.item.kind); item.command = { command: 'vscode.open', - title: 'Open Type', + title: localize('title.openType', 'Open Type'), arguments: [ element.item.uri, { selection: element.item.selectionRange.with({ end: element.item.selectionRange.start }) } diff --git a/extensions/references-view/yarn.lock b/extensions/references-view/yarn.lock index 4b3f8a1f7a0..0f041514ffc 100644 --- a/extensions/references-view/yarn.lock +++ b/extensions/references-view/yarn.lock @@ -6,3 +6,8 @@ version "16.11.33" resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.33.tgz#566713b1b626f781c5c58fe3531307283e00720c" 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==