From f14868678b6165af9fb8528560b6506798347e82 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Thu, 15 Apr 2021 10:31:22 -0300 Subject: [PATCH] [REGRESSION] Fallback language stopped working (#3072) --- app/i18n/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/i18n/index.js b/app/i18n/index.js index 6ac163a0d..c82e9e17e 100644 --- a/app/i18n/index.js +++ b/app/i18n/index.js @@ -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;