Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix monaco localization #13557

Merged
merged 1 commit into from
Apr 12, 2024
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
16 changes: 0 additions & 16 deletions packages/monaco/src/browser/monaco-frontend-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
17 changes: 17 additions & 0 deletions packages/monaco/src/browser/monaco-init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading