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;