Fix launch crash on devices without fallback languages

This commit is contained in:
Lei Nelissen
2021-03-09 22:21:41 +01:00
parent e4b93ec8c8
commit 76c45623a0

View File

@@ -11,11 +11,16 @@ const localeGetters: Record<string, () => object> = {
};
// Have RNLocalize pick the best locale from the languages on offer
const locale = findBestAvailableLanguage(Object.keys(localeGetters));
let locale = findBestAvailableLanguage(Object.keys(localeGetters));
// Check if the locale is correctly picked
if (!locale || !locale.languageTag) {
throw new Error('Invalid locale selected');
// Some users might not list English as a fallback language, and hence might not
// be assigned a locale. In this case, we'll just default to English.
locale = {
languageTag: 'en',
isRTL: false,
};
}
// Set the key-value pairs for the different languages you want to support.