Skip to content

Commit ba9be48

Browse files
authored
adopt vscode.l10n in references view (microsoft#165245)
microsoft#164438
1 parent cc7114b commit ba9be48

File tree

6 files changed

+20
-33
lines changed

6 files changed

+20
-33
lines changed

extensions/references-view/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,6 @@
406406
"compile": "npx gulp compile-extension:references-view",
407407
"watch": "npx gulp watch-extension:references-view"
408408
},
409-
"dependencies": {
410-
"vscode-nls": "^5.2.0"
411-
},
412409
"devDependencies": {
413410
"@types/node": "16.x"
414411
}

extensions/references-view/src/calls/model.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import * as vscode from 'vscode';
77
import { SymbolItemDragAndDrop, SymbolItemEditorHighlights, SymbolItemNavigation, SymbolTreeInput } from '../references-view';
88
import { asResourceUrl, del, getThemeIcon, tail } from '../utils';
9-
import * as nls from 'vscode-nls';
10-
const localize = nls.loadMessageBundle();
119

1210
export class CallsTreeInput implements SymbolTreeInput<CallItem> {
1311

@@ -19,8 +17,8 @@ export class CallsTreeInput implements SymbolTreeInput<CallItem> {
1917
readonly direction: CallsDirection,
2018
) {
2119
this.title = direction === CallsDirection.Incoming
22-
? localize('title.callers', 'Callers Of')
23-
: localize('title.calls', 'Calls From');
20+
? vscode.l10n.t('Callers Of')
21+
: vscode.l10n.t('Calls From');
2422
}
2523

2624
async resolve() {
@@ -35,7 +33,7 @@ export class CallsTreeInput implements SymbolTreeInput<CallItem> {
3533

3634
return {
3735
provider,
38-
get message() { return model.roots.length === 0 ? localize('noresult', 'No results.') : undefined; },
36+
get message() { return model.roots.length === 0 ? vscode.l10n.t('No results.') : undefined; },
3937
navigation: model,
4038
highlights: model,
4139
dnd: model,
@@ -184,7 +182,7 @@ class CallItemDataProvider implements vscode.TreeDataProvider<CallItem> {
184182
item.iconPath = getThemeIcon(element.item.kind);
185183
item.command = {
186184
command: 'vscode.open',
187-
title: localize('open', 'Open Call'),
185+
title: vscode.l10n.t('Open Call'),
188186
arguments: [
189187
element.item.uri,
190188
<vscode.TextDocumentShowOptions>{ selection: element.item.selectionRange.with({ end: element.item.selectionRange.start }) }

extensions/references-view/src/references/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import * as vscode from 'vscode';
77
import { SymbolsTree } from '../tree';
88
import { FileItem, ReferenceItem, ReferencesModel, ReferencesTreeInput } from './model';
9-
import * as nls from 'vscode-nls';
10-
const localize = nls.loadMessageBundle();
119

1210
export function register(tree: SymbolsTree, context: vscode.ExtensionContext): void {
1311

@@ -45,7 +43,7 @@ export function register(tree: SymbolsTree, context: vscode.ExtensionContext): v
4543

4644
if (value === 'view') {
4745
showReferencesDisposable = vscode.commands.registerCommand('editor.action.showReferences', async (uri: vscode.Uri, position: vscode.Position, locations: vscode.Location[]) => {
48-
const input = new ReferencesTreeInput(localize('title', 'References'), new vscode.Location(uri, position), 'vscode.executeReferenceProvider', locations);
46+
const input = new ReferencesTreeInput(vscode.l10n.t('References'), new vscode.Location(uri, position), 'vscode.executeReferenceProvider', locations);
4947
tree.setInput(input);
5048
});
5149
}

extensions/references-view/src/references/model.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import * as vscode from 'vscode';
77
import { SymbolItemDragAndDrop, SymbolItemEditorHighlights, SymbolItemNavigation, SymbolTreeInput, SymbolTreeModel } from '../references-view';
88
import { asResourceUrl, del, getPreviewChunks, tail } from '../utils';
9-
import * as nls from 'vscode-nls';
10-
const localize = nls.loadMessageBundle();
119

1210
export class ReferencesTreeInput implements SymbolTreeInput<FileItem | ReferenceItem> {
1311

@@ -112,18 +110,18 @@ export class ReferencesModel implements SymbolItemNavigation<FileItem | Referenc
112110

113111
get message() {
114112
if (this.items.length === 0) {
115-
return localize('noresult', 'No results.');
113+
return vscode.l10n.t('No results.');
116114
}
117115
const total = this.items.reduce((prev, cur) => prev + cur.references.length, 0);
118116
const files = this.items.length;
119117
if (total === 1 && files === 1) {
120-
return localize('result.1', '{0} result in {1} file', total, files);
118+
return vscode.l10n.t('{0} result in {1} file', total, files);
121119
} else if (total === 1) {
122-
return localize('result.1n', '{0} result in {1} files', total, files);
120+
return vscode.l10n.t('{0} result in {1} files', total, files);
123121
} else if (files === 1) {
124-
return localize('result.n1', '{0} results in {1} file', total, files);
122+
return vscode.l10n.t('{0} results in {1} file', total, files);
125123
} else {
126-
return localize('result.nm', '{0} results in {1} files', total, files);
124+
return vscode.l10n.t('{0} results in {1} files', total, files);
127125
}
128126
}
129127

@@ -299,7 +297,7 @@ class ReferencesTreeDataProvider implements vscode.TreeDataProvider<FileItem | R
299297
result.contextValue = 'reference-item';
300298
result.command = {
301299
command: 'vscode.open',
302-
title: localize('open', 'Open Reference'),
300+
title: vscode.l10n.t('Open Reference'),
303301
arguments: [
304302
element.location.uri,
305303
<vscode.TextDocumentShowOptions>{ selection: range.with({ end: range.start }) }

extensions/references-view/src/tree.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import { EditorHighlights } from './highlights';
88
import { Navigation } from './navigation';
99
import { SymbolItemDragAndDrop, SymbolTreeInput } from './references-view';
1010
import { ContextKey, isValidRequestPosition, WordAnchor } from './utils';
11-
import * as nls from 'vscode-nls';
12-
const localize = nls.loadMessageBundle();
1311

1412

1513
export class SymbolsTree {
@@ -123,10 +121,10 @@ export class SymbolsTree {
123121
this._input = undefined;
124122
this._ctxHasResult.set(false);
125123
this._ctxInputSource.reset();
126-
this._tree.title = localize('title', 'References');
124+
this._tree.title = vscode.l10n.t('References');
127125
this._tree.message = this._history.size === 0
128-
? localize('noresult', 'No results.')
129-
: localize('noresult2', 'No results. Try running a previous search again:');
126+
? vscode.l10n.t('No results.')
127+
: vscode.l10n.t('No results. Try running a previous search again:');
130128
this._provider.update(Promise.resolve(this._history));
131129
}
132130
}
@@ -283,7 +281,7 @@ class TreeInputHistory implements vscode.TreeDataProvider<HistoryItem>{
283281
description: item.description,
284282
item
285283
});
286-
const pick = await vscode.window.showQuickPick(picks, { placeHolder: localize('placeholder', 'Select previous reference search') });
284+
const pick = await vscode.window.showQuickPick(picks, { placeHolder: vscode.l10n.t('Select previous reference search') });
287285
if (pick) {
288286
this._reRunHistoryItem(pick.item);
289287
}
@@ -338,7 +336,7 @@ class TreeInputHistory implements vscode.TreeDataProvider<HistoryItem>{
338336
getTreeItem(item: HistoryItem): vscode.TreeItem {
339337
const result = new vscode.TreeItem(item.word);
340338
result.description = item.description;
341-
result.command = { command: '_references-view.showHistoryItem', arguments: [item], title: localize('title.rerun', 'Rerun') };
339+
result.command = { command: '_references-view.showHistoryItem', arguments: [item], title: vscode.l10n.t('Rerun') };
342340
result.collapsibleState = vscode.TreeItemCollapsibleState.None;
343341
result.contextValue = 'history-item';
344342
return result;

extensions/references-view/src/types/model.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import * as vscode from 'vscode';
77
import { SymbolItemDragAndDrop, SymbolItemEditorHighlights, SymbolItemNavigation, SymbolTreeInput } from '../references-view';
88
import { asResourceUrl, del, getThemeIcon, tail } from '../utils';
9-
import * as nls from 'vscode-nls';
10-
const localize = nls.loadMessageBundle();
119

1210
export class TypesTreeInput implements SymbolTreeInput<TypeItem> {
1311

@@ -19,8 +17,8 @@ export class TypesTreeInput implements SymbolTreeInput<TypeItem> {
1917
readonly direction: TypeHierarchyDirection,
2018
) {
2119
this.title = direction === TypeHierarchyDirection.Supertypes
22-
? localize('title.sup', 'Supertypes Of')
23-
: localize('title.sub', 'Subtypes Of');
20+
? vscode.l10n.t('Supertypes Of')
21+
: vscode.l10n.t('Subtypes Of');
2422
}
2523

2624
async resolve() {
@@ -35,7 +33,7 @@ export class TypesTreeInput implements SymbolTreeInput<TypeItem> {
3533

3634
return {
3735
provider,
38-
get message() { return model.roots.length === 0 ? localize('noresult', 'No results.') : undefined; },
36+
get message() { return model.roots.length === 0 ? vscode.l10n.t('No results.') : undefined; },
3937
navigation: model,
4038
highlights: model,
4139
dnd: model,
@@ -176,7 +174,7 @@ class TypeItemDataProvider implements vscode.TreeDataProvider<TypeItem> {
176174
item.iconPath = getThemeIcon(element.item.kind);
177175
item.command = {
178176
command: 'vscode.open',
179-
title: localize('title.openType', 'Open Type'),
177+
title: vscode.l10n.t('Open Type'),
180178
arguments: [
181179
element.item.uri,
182180
<vscode.TextDocumentShowOptions>{ selection: element.item.selectionRange.with({ end: element.item.selectionRange.start }) }

0 commit comments

Comments
 (0)