fix update of locale moment

This commit is contained in:
Audric Ackermann 2021-03-19 13:51:03 +11:00
parent f5a4094e0a
commit b28687980c
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4
1 changed files with 10 additions and 6 deletions

View File

@ -386,21 +386,25 @@ window.seedNodeList = JSON.parse(config.seedNodeList);
const { OnionPaths } = require('./ts/session/onions');
const { locale } = config;
window.i18n = i18n.setup(locale, localeMessages);
// moment does not support es-419 correctly (and cause white screen on app start)
const localeForMoment = locale === 'es-419' ? 'es' : locale;
const { locale: localFromEnv } = config;
window.i18n = i18n.setup(localFromEnv, localeMessages);
// moment does not support es-419 correctly (and cause white screen on app start)
window.moment = require('moment');
window.moment.updateLocale(localeForMoment, {
// Default to the locale from env. It will be overriden if moment
// does not recognize it with what moment knows which is the closest.
// i.e. es-419 will return 'es'.
// We just need to use what we got from moment on the updateLocale below
const localeSetForMoment = window.moment.locale(localFromEnv);
window.moment.updateLocale(localeSetForMoment, {
relativeTime: {
s: window.i18n('timestamp_s'),
m: window.i18n('timestamp_m'),
h: window.i18n('timestamp_h'),
},
});
window.moment.locale(localeForMoment);
window.OnionPaths = OnionPaths;