Skip to content

Commit 10dc1a3

Browse files
authored
Adopt l10n for media-preview (microsoft#165525)
For microsoft#164438
1 parent eafc1e0 commit 10dc1a3

File tree

8 files changed

+17
-36
lines changed

8 files changed

+17
-36
lines changed

extensions/media-preview/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@
101101
"watch-web": "npx webpack-cli --config extension-browser.webpack.config --mode none --watch --info-verbosity verbose"
102102
},
103103
"dependencies": {
104-
"@vscode/extension-telemetry": "0.6.2",
105-
"vscode-nls": "^5.2.0"
104+
"@vscode/extension-telemetry": "0.6.2"
106105
},
107106
"repository": {
108107
"type": "git",

extensions/media-preview/src/audioPreview.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as vscode from 'vscode';
7-
import * as nls from 'vscode-nls';
87
import { BinarySizeStatusBarEntry } from './binarySizeStatusBarEntry';
98
import { MediaPreview, reopenAsText } from './mediaPreview';
109
import { escapeAttribute, getNonce } from './util/dom';
1110

12-
const localize = nls.loadMessageBundle();
13-
1411
class AudioPreviewProvider implements vscode.CustomReadonlyEditorProvider {
1512

1613
public static readonly viewType = 'vscode.audioPreview';
@@ -82,8 +79,8 @@ class AudioPreview extends MediaPreview {
8279
<body class="container loading">
8380
<div class="loading-indicator"></div>
8481
<div class="loading-error">
85-
<p>${localize('preview.audioLoadError', "An error occurred while loading the audio file.")}</p>
86-
<a href="#" class="open-file-link">${localize('preview.audioLoadErrorLink', "Open file using VS Code's standard text/binary editor?")}</a>
82+
<p>${vscode.l10n.t("An error occurred while loading the audio file.")}</p>
83+
<a href="#" class="open-file-link">${vscode.l10n.t("Open file using VS Code's standard text/binary editor?")}</a>
8784
</div>
8885
<script src="${escapeAttribute(this.extensionResource('media', 'audioPreview.js'))}" nonce="${nonce}"></script>
8986
</body>

extensions/media-preview/src/binarySizeStatusBarEntry.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as vscode from 'vscode';
7-
import * as nls from 'vscode-nls';
87
import { PreviewStatusBarEntry } from './ownedStatusBarEntry';
98

10-
const localize = nls.loadMessageBundle();
119

1210
class BinarySize {
1311
static readonly KB = 1024;
@@ -17,29 +15,29 @@ class BinarySize {
1715

1816
static formatSize(size: number): string {
1917
if (size < BinarySize.KB) {
20-
return localize('sizeB', "{0}B", size);
18+
return vscode.l10n.t("{0}B", size);
2119
}
2220

2321
if (size < BinarySize.MB) {
24-
return localize('sizeKB', "{0}KB", (size / BinarySize.KB).toFixed(2));
22+
return vscode.l10n.t("{0}KB", (size / BinarySize.KB).toFixed(2));
2523
}
2624

2725
if (size < BinarySize.GB) {
28-
return localize('sizeMB', "{0}MB", (size / BinarySize.MB).toFixed(2));
26+
return vscode.l10n.t("{0}MB", (size / BinarySize.MB).toFixed(2));
2927
}
3028

3129
if (size < BinarySize.TB) {
32-
return localize('sizeGB', "{0}GB", (size / BinarySize.GB).toFixed(2));
30+
return vscode.l10n.t("{0}GB", (size / BinarySize.GB).toFixed(2));
3331
}
3432

35-
return localize('sizeTB', "{0}TB", (size / BinarySize.TB).toFixed(2));
33+
return vscode.l10n.t("{0}TB", (size / BinarySize.TB).toFixed(2));
3634
}
3735
}
3836

3937
export class BinarySizeStatusBarEntry extends PreviewStatusBarEntry {
4038

4139
constructor() {
42-
super('status.imagePreview.binarySize', localize('sizeStatusBar.name', "Image Binary Size"), vscode.StatusBarAlignment.Right, 100);
40+
super('status.imagePreview.binarySize', vscode.l10n.t("Image Binary Size"), vscode.StatusBarAlignment.Right, 100);
4341
}
4442

4543
public show(owner: unknown, size: number | undefined) {

extensions/media-preview/src/imagePreview/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as vscode from 'vscode';
7-
import * as nls from 'vscode-nls';
87
import { BinarySizeStatusBarEntry } from '../binarySizeStatusBarEntry';
98
import { MediaPreview, PreviewState, reopenAsText } from '../mediaPreview';
109
import { escapeAttribute, getNonce } from '../util/dom';
1110
import { SizeStatusBarEntry } from './sizeStatusBarEntry';
1211
import { Scale, ZoomStatusBarEntry } from './zoomStatusBarEntry';
1312

14-
const localize = nls.loadMessageBundle();
1513

1614
export class PreviewManager implements vscode.CustomReadonlyEditorProvider {
1715

@@ -181,8 +179,8 @@ class ImagePreview extends MediaPreview {
181179
<body class="container image scale-to-fit loading">
182180
<div class="loading-indicator"></div>
183181
<div class="image-load-error">
184-
<p>${localize('preview.imageLoadError', "An error occurred while loading the image.")}</p>
185-
<a href="#" class="open-file-link">${localize('preview.imageLoadErrorLink', "Open file using VS Code's standard text/binary editor?")}</a>
182+
<p>${vscode.l10n.t("An error occurred while loading the image.")}</p>
183+
<a href="#" class="open-file-link">${vscode.l10n.t("Open file using VS Code's standard text/binary editor?")}</a>
186184
</div>
187185
<script src="${escapeAttribute(this.extensionResource('media', 'imagePreview.js'))}" nonce="${nonce}"></script>
188186
</body>

extensions/media-preview/src/imagePreview/sizeStatusBarEntry.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as vscode from 'vscode';
7-
import * as nls from 'vscode-nls';
87
import { PreviewStatusBarEntry } from '../ownedStatusBarEntry';
98

10-
const localize = nls.loadMessageBundle();
119

1210
export class SizeStatusBarEntry extends PreviewStatusBarEntry {
1311

1412
constructor() {
15-
super('status.imagePreview.size', localize('sizeStatusBar.name', "Image Size"), vscode.StatusBarAlignment.Right, 101 /* to the left of editor status (100) */);
13+
super('status.imagePreview.size', vscode.l10n.t("Image Size"), vscode.StatusBarAlignment.Right, 101 /* to the left of editor status (100) */);
1614
}
1715

1816
public show(owner: unknown, text: string) {

extensions/media-preview/src/imagePreview/zoomStatusBarEntry.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as vscode from 'vscode';
7-
import * as nls from 'vscode-nls';
87
import { PreviewStatusBarEntry as OwnedStatusBarEntry } from '../ownedStatusBarEntry';
98

10-
const localize = nls.loadMessageBundle();
119

1210
const selectZoomLevelCommandId = '_imagePreview.selectZoomLevel';
1311

@@ -19,7 +17,7 @@ export class ZoomStatusBarEntry extends OwnedStatusBarEntry {
1917
public readonly onDidChangeScale = this._onDidChangeScale.event;
2018

2119
constructor() {
22-
super('status.imagePreview.zoom', localize('zoomStatusBar.name', "Image Zoom"), vscode.StatusBarAlignment.Right, 102 /* to the left of editor size entry (101) */);
20+
super('status.imagePreview.zoom', vscode.l10n.t("Image Zoom"), vscode.StatusBarAlignment.Right, 102 /* to the left of editor size entry (101) */);
2321

2422
this._register(vscode.commands.registerCommand(selectZoomLevelCommandId, async () => {
2523
type MyPickItem = vscode.QuickPickItem & { scale: Scale };
@@ -31,7 +29,7 @@ export class ZoomStatusBarEntry extends OwnedStatusBarEntry {
3129
}));
3230

3331
const pick = await vscode.window.showQuickPick(options, {
34-
placeHolder: localize('zoomStatusBar.placeholder', "Select zoom level")
32+
placeHolder: vscode.l10n.t("Select zoom level")
3533
});
3634
if (pick) {
3735
this._onDidChangeScale.fire({ scale: pick.scale });
@@ -47,7 +45,7 @@ export class ZoomStatusBarEntry extends OwnedStatusBarEntry {
4745

4846
private zoomLabel(scale: Scale): string {
4947
return scale === 'fit'
50-
? localize('zoomStatusBar.wholeImageLabel', "Whole Image")
48+
? vscode.l10n.t("Whole Image")
5149
: `${Math.round(scale * 100)}%`;
5250
}
5351
}

extensions/media-preview/src/videoPreview.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as vscode from 'vscode';
7-
import * as nls from 'vscode-nls';
87
import { BinarySizeStatusBarEntry } from './binarySizeStatusBarEntry';
98
import { MediaPreview, reopenAsText } from './mediaPreview';
109
import { escapeAttribute, getNonce } from './util/dom';
1110

12-
const localize = nls.loadMessageBundle();
1311

1412
class VideoPreviewProvider implements vscode.CustomReadonlyEditorProvider {
1513

@@ -82,8 +80,8 @@ class VideoPreview extends MediaPreview {
8280
<body class="loading">
8381
<div class="loading-indicator"></div>
8482
<div class="loading-error">
85-
<p>${localize('preview.videoLoadError', "An error occurred while loading the video file.")}</p>
86-
<a href="#" class="open-file-link">${localize('preview.videoLoadErrorLink', "Open file using VS Code's standard text/binary editor?")}</a>
83+
<p>${vscode.l10n.t("An error occurred while loading the video file.")}</p>
84+
<a href="#" class="open-file-link">${vscode.l10n.t("Open file using VS Code's standard text/binary editor?")}</a>
8785
</div>
8886
<script src="${escapeAttribute(this.extensionResource('media', 'videoPreview.js'))}" nonce="${nonce}"></script>
8987
</body>

extensions/media-preview/yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,3 @@
4545
dependencies:
4646
"@microsoft/1ds-core-js" "^3.2.3"
4747
"@microsoft/1ds-post-js" "^3.2.3"
48-
49-
vscode-nls@^5.2.0:
50-
version "5.2.0"
51-
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.2.0.tgz#3cb6893dd9bd695244d8a024bdf746eea665cc3f"
52-
integrity sha512-RAaHx7B14ZU04EU31pT+rKz2/zSl7xMsfIZuo8pd+KZO6PXtQmpevpq3vxvWNcrGbdmhM/rr5Uw5Mz+NBfhVng==

0 commit comments

Comments
 (0)