diff --git a/preload.js b/preload.js index 74aedbe80..5322257b0 100644 --- a/preload.js +++ b/preload.js @@ -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;