From 5b858e2f0621cc0885aa2cbbe4179b7cf11b0f96 Mon Sep 17 00:00:00 2001 From: Mattermost Build Date: Thu, 12 Sep 2019 16:57:34 +0200 Subject: [PATCH] Automated cherry pick of #3238 (#3255) * 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]; }