This commit is contained in:
Lucas Verney 2018-03-06 18:31:37 +01:00
parent 09e0c4f883
commit e128171ddc

View File

@ -39,6 +39,13 @@ export function getBestMatchingLocale(messages, defaultLocale = 'en') {
let bestLocale = defaultLocale; let bestLocale = defaultLocale;
// Get best matching locale // Get best matching locale
locales.some(locale => (messages[locale] && (bestLocale = locale))); locales.some((locale) => {
if (messages[locale]) {
bestLocale = locale;
// Stop at first matching locale
return true;
}
return false;
});
return bestLocale; return bestLocale;
} }