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

Improve localization for preferences and monaco #12378

Merged
merged 3 commits into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions examples/playwright/src/tests/theia-main-menu.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ test.describe('Theia Main Menu', () => {

test('should be able to show menu item in submenu by path', async () => {
const mainMenu = await menuBar.openMenu('File');
const openPreferencesItem = await mainMenu.menuItemByNamePath('Preferences', 'Open Settings (UI)');
const openPreferencesItem = await mainMenu.menuItemByNamePath('Preferences', 'Settings');

const label = await openPreferencesItem?.label();
expect(label).toBe('Open Settings (UI)');
expect(label).toBe('Settings');
});

test('should close main menu', async () => {
Expand Down
2 changes: 2 additions & 0 deletions packages/keymaps/src/browser/keymaps-frontend-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,12 @@ export class KeymapsFrontendContribution extends AbstractViewContribution<Keybin
override registerMenus(menus: MenuModelRegistry): void {
menus.registerMenuAction(CommonMenus.FILE_SETTINGS_SUBMENU_OPEN, {
commandId: KeymapsCommands.OPEN_KEYMAPS.id,
label: nls.localizeByDefault('Keyboard Shortcuts'),
order: 'a20'
});
menus.registerMenuAction(CommonMenus.SETTINGS_OPEN, {
commandId: KeymapsCommands.OPEN_KEYMAPS.id,
label: nls.localizeByDefault('Keyboard Shortcuts'),
order: 'a20'
});
}
Expand Down
3 changes: 2 additions & 1 deletion packages/monaco/src/browser/monaco-formatting-conflicts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import * as monaco from '@theia/monaco-editor-core';
import { FormattingConflicts, FormattingMode } from '@theia/monaco-editor-core/esm/vs/editor/contrib/format/browser/format';
import { DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider } from '@theia/monaco-editor-core/esm/vs/editor/common/languages';
import { ITextModel } from '@theia/monaco-editor-core/esm/vs/editor/common/model';
import { nls } from '@theia/core/lib/common/nls';

type FormattingEditProvider = DocumentFormattingEditProvider | DocumentRangeFormattingEditProvider;

Expand Down Expand Up @@ -103,7 +104,7 @@ export class MonacoFormattingConflictsContribution implements FrontendApplicatio
}))
.sort((a, b) => a.label!.localeCompare(b.label!));

const selectedFormatter = await this.monacoQuickInputService.showQuickPick(items, { placeholder: 'Select formatter for the current document' });
const selectedFormatter = await this.monacoQuickInputService.showQuickPick(items, { placeholder: nls.localizeByDefault('Format Document With...') });
if (selectedFormatter) {
this.setDefaultFormatter(languageId, selectedFormatter.detail ? selectedFormatter.detail : '');
resolve(selectedFormatter.value);
Expand Down
8 changes: 4 additions & 4 deletions packages/monaco/src/browser/monaco-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { EndOfLineSequence } from '@theia/monaco-editor-core/esm/vs/editor/commo
import { SnippetParser } from '@theia/monaco-editor-core/esm/vs/editor/contrib/snippet/browser/snippetParser';
import { TextEdit } from '@theia/monaco-editor-core/esm/vs/editor/common/languages';
import { SnippetController2 } from '@theia/monaco-editor-core/esm/vs/editor/contrib/snippet/browser/snippetController2';
import { isObject, MaybePromise } from '@theia/core/lib/common';
import { isObject, MaybePromise, nls } from '@theia/core/lib/common';

export namespace WorkspaceFileEdit {
export function is(arg: Edit): arg is monaco.languages.IWorkspaceFileEdit {
Expand Down Expand Up @@ -280,12 +280,12 @@ export class MonacoWorkspace {

protected getAriaSummary(totalEdits: number, totalFiles: number): string {
if (totalEdits === 0) {
return 'Made no edits';
return nls.localizeByDefault('Made no edits');
}
if (totalEdits > 1 && totalFiles > 1) {
return `Made ${totalEdits} text edits in ${totalFiles} files`;
return nls.localizeByDefault('Made {0} text edits in {1} files', totalEdits, totalFiles);
}
return `Made ${totalEdits} text edits in one file`;
return nls.localizeByDefault('Made {0} text edits in one file', totalEdits);
}

protected async performTextEdits(edits: MonacoResourceTextEdit[]): Promise<{
Expand Down
13 changes: 0 additions & 13 deletions packages/plugin-ext/src/main/browser/style/test.svg

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class PluginViewRegistry implements FrontendApplicationContribution {
}
});
this.doRegisterViewContainer('test', 'left', {
label: 'Test',
label: nls.localizeByDefault('Test'),
iconClass: codicon('beaker'),
closeable: true
});
Expand Down
6 changes: 3 additions & 3 deletions packages/preferences/src/browser/preferences-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// *****************************************************************************

import { injectable, inject, named, optional } from '@theia/core/shared/inversify';
import { MenuModelRegistry, CommandRegistry } from '@theia/core';
import { MenuModelRegistry, CommandRegistry, nls } from '@theia/core';
import {
CommonMenus,
AbstractViewContribution,
Expand Down Expand Up @@ -143,12 +143,12 @@ export class PreferencesContribution extends AbstractViewContribution<Preference
override registerMenus(menus: MenuModelRegistry): void {
menus.registerMenuAction(CommonMenus.FILE_SETTINGS_SUBMENU_OPEN, {
commandId: CommonCommands.OPEN_PREFERENCES.id,
label: CommonCommands.OPEN_PREFERENCES.label,
label: nls.localizeByDefault('Settings'),
order: 'a10',
});
menus.registerMenuAction(CommonMenus.SETTINGS_OPEN, {
commandId: CommonCommands.OPEN_PREFERENCES.id,
label: CommonCommands.OPEN_PREFERENCES.label,
label: nls.localizeByDefault('Settings'),
order: 'a10',
});
menus.registerMenuAction(PreferenceMenus.PREFERENCE_EDITOR_CONTEXT_MENU, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class PreferencesWidget extends Panel implements StatefulWidget {
/**
* The widget `label` which is used for display purposes.
*/
static readonly LABEL = nls.localizeByDefault('Preferences');
static readonly LABEL = nls.localizeByDefault('Settings');

@inject(PreferencesEditorWidget) protected readonly editorWidget: PreferencesEditorWidget;
@inject(PreferencesTreeWidget) protected readonly treeWidget: PreferencesTreeWidget;
Expand Down