[REGRESSION] Fallback language stopped working (#3072)

This commit is contained in:
Diego Mello 2021-04-15 10:31:22 -03:00 committed by GitHub
parent 14078c0943
commit f14868678b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -79,13 +79,16 @@ export const setLanguage = (l) => {
return;
}
// server uses lowercase pattern (pt-br), but we're forced to use standard pattern (pt-BR)
const locale = LANGUAGES.find(ll => ll.value.toLowerCase() === l.toLowerCase())?.value;
let locale = LANGUAGES.find(ll => ll.value.toLowerCase() === l.toLowerCase())?.value;
if (!locale) {
locale = 'en';
}
// don't go forward if it's the same language and default language (en) was setup already
if (i18n.locale === locale && i18n.translations?.en) {
return;
}
i18n.locale = locale;
i18n.translations = { ...i18n.translations, [locale]: translations[locale]() };
i18n.translations = { ...i18n.translations, [locale]: translations[locale]?.() };
I18nManager.forceRTL(isRTL(locale));
I18nManager.swapLeftAndRightInRTL(isRTL(locale));
i18n.isRTL = I18nManager.isRTL;