Adopt l10n for media-preview (#165525)

For #164438
This commit is contained in:
Matt Bierner
2022-11-04 10:57:02 -07:00
committed by GitHub
parent eafc1e0fe1
commit 10dc1a34b5
8 changed files with 17 additions and 36 deletions

View File

@@ -4,14 +4,12 @@
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
import { BinarySizeStatusBarEntry } from '../binarySizeStatusBarEntry';
import { MediaPreview, PreviewState, reopenAsText } from '../mediaPreview';
import { escapeAttribute, getNonce } from '../util/dom';
import { SizeStatusBarEntry } from './sizeStatusBarEntry';
import { Scale, ZoomStatusBarEntry } from './zoomStatusBarEntry';
const localize = nls.loadMessageBundle();
export class PreviewManager implements vscode.CustomReadonlyEditorProvider {
@@ -181,8 +179,8 @@ class ImagePreview extends MediaPreview {
<body class="container image scale-to-fit loading">
<div class="loading-indicator"></div>
<div class="image-load-error">
<p>${localize('preview.imageLoadError', "An error occurred while loading the image.")}</p>
<a href="#" class="open-file-link">${localize('preview.imageLoadErrorLink', "Open file using VS Code's standard text/binary editor?")}</a>
<p>${vscode.l10n.t("An error occurred while loading the image.")}</p>
<a href="#" class="open-file-link">${vscode.l10n.t("Open file using VS Code's standard text/binary editor?")}</a>
</div>
<script src="${escapeAttribute(this.extensionResource('media', 'imagePreview.js'))}" nonce="${nonce}"></script>
</body>

View File

@@ -4,15 +4,13 @@
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
import { PreviewStatusBarEntry } from '../ownedStatusBarEntry';
const localize = nls.loadMessageBundle();
export class SizeStatusBarEntry extends PreviewStatusBarEntry {
constructor() {
super('status.imagePreview.size', localize('sizeStatusBar.name', "Image Size"), vscode.StatusBarAlignment.Right, 101 /* to the left of editor status (100) */);
super('status.imagePreview.size', vscode.l10n.t("Image Size"), vscode.StatusBarAlignment.Right, 101 /* to the left of editor status (100) */);
}
public show(owner: unknown, text: string) {

View File

@@ -4,10 +4,8 @@
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
import { PreviewStatusBarEntry as OwnedStatusBarEntry } from '../ownedStatusBarEntry';
const localize = nls.loadMessageBundle();
const selectZoomLevelCommandId = '_imagePreview.selectZoomLevel';
@@ -19,7 +17,7 @@ export class ZoomStatusBarEntry extends OwnedStatusBarEntry {
public readonly onDidChangeScale = this._onDidChangeScale.event;
constructor() {
super('status.imagePreview.zoom', localize('zoomStatusBar.name', "Image Zoom"), vscode.StatusBarAlignment.Right, 102 /* to the left of editor size entry (101) */);
super('status.imagePreview.zoom', vscode.l10n.t("Image Zoom"), vscode.StatusBarAlignment.Right, 102 /* to the left of editor size entry (101) */);
this._register(vscode.commands.registerCommand(selectZoomLevelCommandId, async () => {
type MyPickItem = vscode.QuickPickItem & { scale: Scale };
@@ -31,7 +29,7 @@ export class ZoomStatusBarEntry extends OwnedStatusBarEntry {
}));
const pick = await vscode.window.showQuickPick(options, {
placeHolder: localize('zoomStatusBar.placeholder', "Select zoom level")
placeHolder: vscode.l10n.t("Select zoom level")
});
if (pick) {
this._onDidChangeScale.fire({ scale: pick.scale });
@@ -47,7 +45,7 @@ export class ZoomStatusBarEntry extends OwnedStatusBarEntry {
private zoomLabel(scale: Scale): string {
return scale === 'fit'
? localize('zoomStatusBar.wholeImageLabel', "Whole Image")
? vscode.l10n.t("Whole Image")
: `${Math.round(scale * 100)}%`;
}
}