MM-18226 Set moment timezone locale as needed to prevent moment and intl locale getting out of sync (#3238)

* Set moment timezone locale as needed to prevent moment and intl locale getting out of sync

* Update app/i18n/index.js

Co-Authored-By: Elias Nahum <nahumhbl@gmail.com>

* Updates per feedback
This commit is contained in:
Joram Wilander 2019-09-12 10:51:22 -04:00 committed by Miguel de la Cruz
parent 72d1895bd3
commit 59d75eeb87

View file

@ -108,10 +108,21 @@ function loadTranslation(locale) {
}
}
let momentLocale = DEFAULT_LOCALE;
function setMomentLocale(locale) {
if (momentLocale !== locale) {
momentLocale = moment.locale(locale);
}
}
export function getTranslations(locale) {
if (!TRANSLATIONS[locale]) {
loadTranslation(locale);
}
setMomentLocale(locale.toLowerCase());
return TRANSLATIONS[locale] || TRANSLATIONS[DEFAULT_LOCALE];
}