1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-18 20:59:44 +02:00

feat: Fallback to English if translation is missing

Closes #175
This commit is contained in:
Maksim Eltyshev 2022-04-21 04:42:02 +05:00
parent d5a6f57fa7
commit 952fdacb6a
3 changed files with 11 additions and 4 deletions

View file

@ -58,7 +58,7 @@ i18n
.use(initReactI18next)
.init({
resources: embedLocales,
fallbackLng: false,
fallbackLng: 'en',
supportedLngs: languages,
load: 'languageOnly',
interpolation: {
@ -79,7 +79,11 @@ i18n
debug: process.env.NODE_ENV !== 'production',
});
i18n.loadCoreLocale = (language) =>
i18n.loadCoreLocale = (language = i18n.resolvedLanguage) => {
if (language === 'en') {
return;
}
import(`./locales/${language}/core`).then((module) => {
const locale = module.default;
@ -91,5 +95,6 @@ i18n.loadCoreLocale = (language) =>
}
});
});
};
export default i18n;

View file

@ -1,9 +1,11 @@
import merge from 'lodash/merge';
import fromPairs from 'lodash/fromPairs';
import csLogin from './cs/login';
import daLogin from './da/login';
import deLogin from './de/login';
import enLogin from './en/login';
import enCore from './en/core';
import esLogin from './es/login';
import frLogin from './fr/login';
import jaLogin from './ja/login';
@ -16,7 +18,7 @@ const localePairs = [
['cs', csLogin],
['da', daLogin],
['de', deLogin],
['en', enLogin],
['en', merge(enLogin, enCore)],
['es', esLogin],
['fr', frLogin],
['ja', jaLogin],

View file

@ -25,7 +25,7 @@ export function* initializeCoreService() {
notifications,
} = yield call(fetchCoreRequest); // TODO: handle error
yield call(i18n.loadCoreLocale, i18n.resolvedLanguage);
yield call(i18n.loadCoreLocale);
yield put(
initializeCore(