mirror of
https://github.com/Microsoft/vscode
synced 2024-10-30 06:38:23 +00:00
adopt vscode.l10n
in references view (#165245)
https://github.com/microsoft/vscode/issues/164438
This commit is contained in:
parent
cc7114b3ba
commit
ba9be48390
6 changed files with 20 additions and 33 deletions
|
@ -406,9 +406,6 @@
|
||||||
"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.2.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "16.x"
|
"@types/node": "16.x"
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
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> {
|
||||||
|
|
||||||
|
@ -19,8 +17,8 @@ export class CallsTreeInput implements SymbolTreeInput<CallItem> {
|
||||||
readonly direction: CallsDirection,
|
readonly direction: CallsDirection,
|
||||||
) {
|
) {
|
||||||
this.title = direction === CallsDirection.Incoming
|
this.title = direction === CallsDirection.Incoming
|
||||||
? localize('title.callers', 'Callers Of')
|
? vscode.l10n.t('Callers Of')
|
||||||
: localize('title.calls', 'Calls From');
|
: vscode.l10n.t('Calls From');
|
||||||
}
|
}
|
||||||
|
|
||||||
async resolve() {
|
async resolve() {
|
||||||
|
@ -35,7 +33,7 @@ export class CallsTreeInput implements SymbolTreeInput<CallItem> {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
provider,
|
provider,
|
||||||
get message() { return model.roots.length === 0 ? localize('noresult', 'No results.') : undefined; },
|
get message() { return model.roots.length === 0 ? vscode.l10n.t('No results.') : undefined; },
|
||||||
navigation: model,
|
navigation: model,
|
||||||
highlights: model,
|
highlights: model,
|
||||||
dnd: model,
|
dnd: model,
|
||||||
|
@ -184,7 +182,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: localize('open', 'Open Call'),
|
title: vscode.l10n.t('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,8 +6,6 @@
|
||||||
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 {
|
||||||
|
|
||||||
|
@ -45,7 +43,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(localize('title', 'References'), new vscode.Location(uri, position), 'vscode.executeReferenceProvider', locations);
|
const input = new ReferencesTreeInput(vscode.l10n.t('References'), new vscode.Location(uri, position), 'vscode.executeReferenceProvider', locations);
|
||||||
tree.setInput(input);
|
tree.setInput(input);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
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> {
|
||||||
|
|
||||||
|
@ -112,18 +110,18 @@ export class ReferencesModel implements SymbolItemNavigation<FileItem | Referenc
|
||||||
|
|
||||||
get message() {
|
get message() {
|
||||||
if (this.items.length === 0) {
|
if (this.items.length === 0) {
|
||||||
return localize('noresult', 'No results.');
|
return vscode.l10n.t('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 localize('result.1', '{0} result in {1} file', total, files);
|
return vscode.l10n.t('{0} result in {1} file', total, files);
|
||||||
} else if (total === 1) {
|
} else if (total === 1) {
|
||||||
return localize('result.1n', '{0} result in {1} files', total, files);
|
return vscode.l10n.t('{0} result in {1} files', total, files);
|
||||||
} else if (files === 1) {
|
} else if (files === 1) {
|
||||||
return localize('result.n1', '{0} results in {1} file', total, files);
|
return vscode.l10n.t('{0} results in {1} file', total, files);
|
||||||
} else {
|
} else {
|
||||||
return localize('result.nm', '{0} results in {1} files', total, files);
|
return vscode.l10n.t('{0} results in {1} files', total, files);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,7 +297,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: localize('open', 'Open Reference'),
|
title: vscode.l10n.t('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,8 +8,6 @@ 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 {
|
||||||
|
@ -123,10 +121,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 = localize('title', 'References');
|
this._tree.title = vscode.l10n.t('References');
|
||||||
this._tree.message = this._history.size === 0
|
this._tree.message = this._history.size === 0
|
||||||
? localize('noresult', 'No results.')
|
? vscode.l10n.t('No results.')
|
||||||
: localize('noresult2', 'No results. Try running a previous search again:');
|
: vscode.l10n.t('No results. Try running a previous search again:');
|
||||||
this._provider.update(Promise.resolve(this._history));
|
this._provider.update(Promise.resolve(this._history));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -283,7 +281,7 @@ class TreeInputHistory implements vscode.TreeDataProvider<HistoryItem>{
|
||||||
description: item.description,
|
description: item.description,
|
||||||
item
|
item
|
||||||
});
|
});
|
||||||
const pick = await vscode.window.showQuickPick(picks, { placeHolder: localize('placeholder', 'Select previous reference search') });
|
const pick = await vscode.window.showQuickPick(picks, { placeHolder: vscode.l10n.t('Select previous reference search') });
|
||||||
if (pick) {
|
if (pick) {
|
||||||
this._reRunHistoryItem(pick.item);
|
this._reRunHistoryItem(pick.item);
|
||||||
}
|
}
|
||||||
|
@ -338,7 +336,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: localize('title.rerun', 'Rerun') };
|
result.command = { command: '_references-view.showHistoryItem', arguments: [item], title: vscode.l10n.t('Rerun') };
|
||||||
result.collapsibleState = vscode.TreeItemCollapsibleState.None;
|
result.collapsibleState = vscode.TreeItemCollapsibleState.None;
|
||||||
result.contextValue = 'history-item';
|
result.contextValue = 'history-item';
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
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> {
|
||||||
|
|
||||||
|
@ -19,8 +17,8 @@ export class TypesTreeInput implements SymbolTreeInput<TypeItem> {
|
||||||
readonly direction: TypeHierarchyDirection,
|
readonly direction: TypeHierarchyDirection,
|
||||||
) {
|
) {
|
||||||
this.title = direction === TypeHierarchyDirection.Supertypes
|
this.title = direction === TypeHierarchyDirection.Supertypes
|
||||||
? localize('title.sup', 'Supertypes Of')
|
? vscode.l10n.t('Supertypes Of')
|
||||||
: localize('title.sub', 'Subtypes Of');
|
: vscode.l10n.t('Subtypes Of');
|
||||||
}
|
}
|
||||||
|
|
||||||
async resolve() {
|
async resolve() {
|
||||||
|
@ -35,7 +33,7 @@ export class TypesTreeInput implements SymbolTreeInput<TypeItem> {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
provider,
|
provider,
|
||||||
get message() { return model.roots.length === 0 ? localize('noresult', 'No results.') : undefined; },
|
get message() { return model.roots.length === 0 ? vscode.l10n.t('No results.') : undefined; },
|
||||||
navigation: model,
|
navigation: model,
|
||||||
highlights: model,
|
highlights: model,
|
||||||
dnd: model,
|
dnd: model,
|
||||||
|
@ -176,7 +174,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: localize('title.openType', 'Open Type'),
|
title: vscode.l10n.t('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 }) }
|
||||||
|
|
Loading…
Reference in a new issue