Skip to content
Snippets Groups Projects
Unverified Commit 4afdb6bb authored by Dalton's avatar Dalton Committed by GitHub
Browse files

Fix issue with moment locale not working (#18943)

* add fn that maps from our locale string to moment's

* use moment with locales

* add a require for the specific locale

* don't require en

* ensure locale is lowercased for moment more generally

* default locale to a string
parent 68a8a031
No related branches found
No related tags found
No related merge requests found
......@@ -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() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment