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

[36304] Load and fall back to english locale due to crowdin bug (#9066)

Oliver Günther95327c7be0de
diff --git a/frontend/src/app/modules/common/i18n/i18n.service.ts b/frontend/src/app/modules/common/i18n/i18n.service.ts
index 8f4430a4afd..d741feeae2c 100644
--- a/frontend/src/app/modules/common/i18n/i18n.service.ts
+++ b/frontend/src/app/modules/common/i18n/i18n.service.ts
@@ -52,7 +52,10 @@ export class I18nService {
}
public t(translateId:string, parameters?:{ [key:string]:any }):string {
- return this._i18n.t(translateId, parameters);
+ // Avoid returning empty translation strings and fall back to english instead
+ // due to translation bugs
+ return this._i18n.t(translateId, parameters) ||
+ this._i18n.t(translateId, { ...parameters, locale: 'en' });
}
public lookup(translateId:string):boolean|undefined {
diff --git a/frontend/src/main.ts b/frontend/src/main.ts
index db17112c150..12e8f1251eb 100644
--- a/frontend/src/main.ts
+++ b/frontend/src/main.ts
@@ -41,7 +41,12 @@ whenDebugging(() => {
});
// Import the correct locale early on
-import(`./locales/${I18n.locale}.js`)
+Promise.all([
+ // untyped module cannot be dynamically imported
+ // @ts-ignore
+ import(/* webpackChunkName: "default-locale" */ `./locales/en.js`),
+ import(/* webpackChunkName: "locale" */ `./locales/${I18n.locale}.js`),
+])
.then(() => {
jQuery(function () {
// Due to the behaviour of the Edge browser we need to wait for 'DOM ready'
@@ -51,4 +56,4 @@ import(`./locales/${I18n.locale}.js`)
jQuery('body').addClass('__ng2-bootstrap-has-run');
});
});
-});
+ });