Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Set loadedLocale directly

Oliver Güntherd3b849812da1
diff --git a/frontend/src/app/shared/components/editor/components/ckeditor/ckeditor-setup.service.ts b/frontend/src/app/shared/components/editor/components/ckeditor/ckeditor-setup.service.ts
index 9bb96520dff..e4d5d7dfcdd 100644
--- a/frontend/src/app/shared/components/editor/components/ckeditor/ckeditor-setup.service.ts
+++ b/frontend/src/app/shared/components/editor/components/ckeditor/ckeditor-setup.service.ts
@@ -41,8 +41,8 @@ export class CKEditorSetupService {
wrapper:HTMLElement, context:ICKEditorContext,
initialData:string|null = null,
):Promise<ICKEditorWatchdog> {
- // Load the bundle
- this.loadedLocale = await CKEditorSetupService.load();
+ // Load the bundle and the matching locale, if found.
+ await this.load();
const { type } = context;
const editorClass = type === 'constrained' ? window.OPConstrainedEditor : window.OPClassicEditor;
@@ -104,25 +104,19 @@ export class CKEditorSetupService {
/**
* Load the ckeditor asset
*/
- private static async load():Promise<string> {
+ private async load():Promise<void> {
// untyped module cannot be dynamically imported
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
await import(/* webpackChunkName: "ckeditor" */ 'core-vendor/ckeditor/ckeditor.js');
- /** If we're on the english locale, there is no file to load */
- if (I18n.locale === 'en') {
- return 'en';
- }
-
try {
await import(
/* webpackChunkName: "ckeditor-translation" */ `../../../../../../vendor/ckeditor/translations/${I18n.locale}.js`
) as unknown;
- return I18n.locale;
+ this.loadedLocale = I18n.locale;
} catch (e:unknown) {
console.warn(`Failed to load translation for CKEditor: ${e as string}`);
- return 'en';
}
}