From 59d75eeb87f947c41d8376aa4447ccde1fd8afcd Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Thu, 12 Sep 2019 10:51:22 -0400 Subject: [PATCH] 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 * Updates per feedback --- app/i18n/index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/i18n/index.js b/app/i18n/index.js index 4a2404c3f..1fe215879 100644 --- a/app/i18n/index.js +++ b/app/i18n/index.js @@ -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]; }