Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nls: add additional localizations #11368

Merged
merged 3 commits into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { injectable, inject } from '@theia/core/shared/inversify';
import URI from '@theia/core/lib/common/uri';
import { MaybeArray } from '@theia/core/lib/common';
import { MaybeArray, nls } from '@theia/core/lib/common';
import { LabelProvider } from '@theia/core/lib/browser';
import { FileStat } from '../../common/files';
import { DirNode } from '../file-tree';
Expand Down Expand Up @@ -53,7 +53,7 @@ export class DefaultFileDialogService implements FileDialogService {
async showOpenDialog(props: OpenFileDialogProps & { canSelectMany: true }, folder?: FileStat): Promise<MaybeArray<URI> | undefined>;
async showOpenDialog(props: OpenFileDialogProps, folder?: FileStat): Promise<URI | undefined>;
async showOpenDialog(props: OpenFileDialogProps, folder?: FileStat): Promise<MaybeArray<URI> | undefined> {
const title = props.title || 'Open';
const title = props.title || nls.localizeByDefault('Open');
const rootNode = await this.getRootNode(folder);
if (rootNode) {
const dialog = this.openFileDialogFactory(Object.assign(props, { title }));
Expand All @@ -70,7 +70,7 @@ export class DefaultFileDialogService implements FileDialogService {
}

async showSaveDialog(props: SaveFileDialogProps, folder?: FileStat): Promise<URI | undefined> {
const title = props.title || 'Save';
const title = props.title || nls.localizeByDefault('Save');
const rootNode = await this.getRootNode(folder);
if (rootNode) {
const dialog = this.saveFileDialogFactory(Object.assign(props, { title }));
Expand Down
22 changes: 13 additions & 9 deletions packages/filesystem/src/browser/file-dialog/file-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { FileDialogWidget } from './file-dialog-widget';
import { FileDialogTreeFiltersRenderer, FileDialogTreeFilters, FileDialogTreeFiltersRendererFactory } from './file-dialog-tree-filters-renderer';
import URI from '@theia/core/lib/common/uri';
import { Panel } from '@theia/core/shared/@phosphor/widgets';
import * as DOMPurify from '@theia/core/shared/dompurify';

export const OpenFileDialogFactory = Symbol('OpenFileDialogFactory');
export interface OpenFileDialogFactory {
Expand Down Expand Up @@ -153,16 +154,19 @@ export abstract class FileDialog<T> extends AbstractDialog<T> {

navigationPanel.appendChild(this.back = createIconButton(...codiconArray('chevron-left', true)));
this.back.classList.add(NAVIGATION_BACK_CLASS);
this.back.title = 'Navigate Back';
this.back.title = nls.localize('theia/filesystem/dialog/navigateBack', 'Navigate Back');

navigationPanel.appendChild(this.forward = createIconButton(...codiconArray('chevron-right', true)));
this.forward.classList.add(NAVIGATION_FORWARD_CLASS);
this.forward.title = 'Navigate Forward';
this.forward.title = nls.localize('theia/filesystem/dialog/navigateForward', 'Navigate Forward');

navigationPanel.appendChild(this.home = createIconButton(...codiconArray('home', true)));
this.home.classList.add(NAVIGATION_HOME_CLASS);
this.home.title = 'Go To Initial Location';
this.home.title = nls.localize('theia/filesystem/dialog/initialLocation', 'Go To Initial Location');

navigationPanel.appendChild(this.up = createIconButton(...codiconArray('arrow-up', true)));
this.up.classList.add(NAVIGATION_UP_CLASS);
this.up.title = 'Navigate Up One Directory';
this.up.title = nls.localize('theia/filesystem/dialog/navigateUp', 'Navigate Up One Directory');

const locationListRendererHost = document.createElement('div');
this.locationListRenderer = this.locationListFactory({ model: this.model, host: locationListRendererHost });
Expand Down Expand Up @@ -229,7 +233,7 @@ export abstract class FileDialog<T> extends AbstractDialog<T> {
this.contentNode.appendChild(filtersPanel);

const titlePanel = document.createElement('div');
titlePanel.innerHTML = 'Format:';
titlePanel.innerHTML = DOMPurify.sanitize(nls.localize('theia/filesystem/format', 'Format:'));
titlePanel.classList.add(FILTERS_LABEL_CLASS);
filtersPanel.appendChild(titlePanel);

Expand Down Expand Up @@ -308,12 +312,12 @@ export class OpenFileDialog extends FileDialog<MaybeArray<FileStatNode>> {
}

protected getAcceptButtonLabel(): string {
return this.props.openLabel ? this.props.openLabel : 'Open';
return this.props.openLabel ? this.props.openLabel : nls.localizeByDefault('Open');
}

protected override isValid(value: MaybeArray<FileStatNode>): string {
if (value && !this.props.canSelectMany && value instanceof Array) {
return 'You can select only one item';
return nls.localize('theia/filesystem/dialog/multipleItemMessage', 'You can select only one item');
}
return '';
}
Expand Down Expand Up @@ -358,7 +362,7 @@ export class SaveFileDialog extends FileDialog<URI | undefined> {
}

protected getAcceptButtonLabel(): string {
return this.props.saveLabel ? this.props.saveLabel : 'Save';
return this.props.saveLabel ? this.props.saveLabel : nls.localizeByDefault('Save');
}

protected override onUpdateRequest(msg: Message): void {
Expand Down Expand Up @@ -407,7 +411,7 @@ export class SaveFileDialog extends FileDialog<URI | undefined> {
this.contentNode.appendChild(fileNamePanel);

const titlePanel = document.createElement('div');
titlePanel.innerHTML = 'Name:';
titlePanel.innerHTML = DOMPurify.sanitize(nls.localize('theia/filesystem/dialog/name', 'Name:'));
titlePanel.classList.add(FILENAME_LABEL_CLASS);
fileNamePanel.appendChild(titlePanel);

Expand Down