From fd5be308a0da5c1e9f660c3afa86ebe60fc5bf8e Mon Sep 17 00:00:00 2001 From: Mark Sujew Date: Fri, 12 Apr 2024 16:07:31 +0200 Subject: [PATCH] Fix monaco localization (#13557) --- .../src/browser/monaco-frontend-module.ts | 16 ---------------- packages/monaco/src/browser/monaco-init.ts | 17 +++++++++++++++++ .../browser/vsx-language-quick-pick-service.ts | 2 +- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/packages/monaco/src/browser/monaco-frontend-module.ts b/packages/monaco/src/browser/monaco-frontend-module.ts index 0bee7f59228b4..0fc9b9ffaf317 100644 --- a/packages/monaco/src/browser/monaco-frontend-module.ts +++ b/packages/monaco/src/browser/monaco-frontend-module.ts @@ -14,22 +14,6 @@ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 // ***************************************************************************** -import * as MonacoNls from '@theia/monaco-editor-core/esm/vs/nls'; -import { nls } from '@theia/core/lib/common/nls'; -import { FormatType, Localization } from '@theia/core/lib/common/i18n/localization'; - -Object.assign(MonacoNls, { - localize(_key: string, label: string, ...args: FormatType[]): string { - if (nls.locale) { - const defaultKey = nls.getDefaultKey(label); - if (defaultKey) { - return nls.localize(defaultKey, label, ...args); - } - } - return Localization.format(label, args); - } -}); - import '../../src/browser/style/index.css'; import { ContainerModule, interfaces } from '@theia/core/shared/inversify'; import { MenuContribution, CommandContribution, quickInputServicePath } from '@theia/core/lib/common'; diff --git a/packages/monaco/src/browser/monaco-init.ts b/packages/monaco/src/browser/monaco-init.ts index 80ec1fd2d8338..d622e596c3df5 100644 --- a/packages/monaco/src/browser/monaco-init.ts +++ b/packages/monaco/src/browser/monaco-init.ts @@ -27,6 +27,23 @@ * is allowed. */ +// Before importing anything from monaco we need to override its localization function +import * as MonacoNls from '@theia/monaco-editor-core/esm/vs/nls'; +import { nls } from '@theia/core/lib/common/nls'; +import { FormatType, Localization } from '@theia/core/lib/common/i18n/localization'; + +Object.assign(MonacoNls, { + localize(_key: string, label: string, ...args: FormatType[]): string { + if (nls.locale) { + const defaultKey = nls.getDefaultKey(label); + if (defaultKey) { + return nls.localize(defaultKey, label, ...args); + } + } + return Localization.format(label, args); + } +}); + import { Container } from '@theia/core/shared/inversify'; import { ICodeEditorService } from '@theia/monaco-editor-core/esm/vs/editor/browser/services/codeEditorService'; import { StandaloneServices } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices'; diff --git a/packages/vsx-registry/src/browser/vsx-language-quick-pick-service.ts b/packages/vsx-registry/src/browser/vsx-language-quick-pick-service.ts index 16d775e3e34e5..6fc219c9247a2 100644 --- a/packages/vsx-registry/src/browser/vsx-language-quick-pick-service.ts +++ b/packages/vsx-registry/src/browser/vsx-language-quick-pick-service.ts @@ -72,7 +72,7 @@ export class VSXLanguageQuickPickService extends LanguageQuickPickService { localizationContribution.localizedLanguageName ?? localizationContribution.languageName ?? localizationContribution.languageId), }); try { - const extensionUri = VSCodeExtensionUri.fromId(extension.extension.name, extension.extension.namespace).toString(); + const extensionUri = VSCodeExtensionUri.fromId(`${extension.extension.namespace}.${extension.extension.name}`).toString(); await this.pluginServer.deploy(extensionUri); } finally { progress.cancel();