diff --git a/frontend/src/metabase/lib/i18n.js b/frontend/src/metabase/lib/i18n.js index e6ce82c3a1ec075211d66c79ba94073cfa237dec..095b4ab1202cd2e6552980f887903cee2a179a53 100644 --- a/frontend/src/metabase/lib/i18n.js +++ b/frontend/src/metabase/lib/i18n.js @@ -74,10 +74,28 @@ export function setLocalization(translationsObject) { // eslint-disable-next-line react-hooks/rules-of-hooks useLocale(locale); - moment.locale(locale); + updateMomentLocale(locale); updateMomentStartOfWeek(locale); } +function updateMomentLocale(locale) { + const momentLocale = mapToMomentLocale(locale); + if (momentLocale !== "en") { + require("moment/locale/" + momentLocale); + } + + moment.locale(momentLocale); +} + +function mapToMomentLocale(locale = "") { + switch (locale) { + case "zh-Hans": + return "zh-cn"; + default: + return locale.toLowerCase(); + } +} + // Format a fixed timestamp in local time to see if the current locale defaults // to using a 24 hour clock. export function isLocale24Hour() {