react-native-localize
Version:
A toolbox for your React Native app localization.
27 lines (26 loc) • 881 B
JavaScript
;
export const getFindBestLanguageTag = locales => languageTags => {
const loweredLanguageTags = languageTags.map(tag => tag.toLowerCase());
for (const currentLocale of locales) {
const {
languageTag,
languageCode,
scriptCode,
countryCode,
isRTL
} = currentLocale;
const combinaisons = [languageTag, !!scriptCode ? languageCode + "-" + scriptCode : null, languageCode + "-" + countryCode, languageCode].filter(value => !!value);
for (const combinaison of combinaisons) {
const loweredCombinaison = combinaison.toLowerCase();
const tagIndex = loweredLanguageTags.indexOf(loweredCombinaison);
const languageTag = languageTags[tagIndex];
if (languageTag && tagIndex !== -1) {
return {
languageTag,
isRTL
};
}
}
}
};
//# sourceMappingURL=utils.js.map