in packages/@fbcmobile-ui/Utils/DateUtils.js [25:44]
export function chooseMomentLocale(locale: string): string {
// make the locale lower case
// will fix crashes caused by "en-GB" (instead of "en-gb") not being found
const localeLowerCase = locale.toLowerCase();
if (moment.locales().includes(localeLowerCase)) {
// check if the locale is included in the array returned by `locales()`
// which (in this case) tells us which locales moment will support
return localeLowerCase;
} else if (moment.locales().includes(localeLowerCase.substring(0, 2))) {
// check if the first two letters of the locale are included in the array
// returned by `locales()` which (in this case) tells us which locales
// moment will support
// will fixes crashes caused by "en-US" not being found, as we'll tell
// moment to load "en" instead
return localeLowerCase.substring(0, 2);
}
// use "en" (the default language and locale for my app) as
// a fallback if we can't find any other locale
return 'en';
}