From 60afbe7b06ea4771b8220d40a4245807a1bc6f3d Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Thu, 4 Feb 2021 09:27:40 +1100 Subject: [PATCH] fallback to es for moment when given locale is es-419 --- preload.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/preload.js b/preload.js index 35bf3bceb..7e5741145 100644 --- a/preload.js +++ b/preload.js @@ -350,20 +350,6 @@ const Signal = require('./js/modules/signal'); const i18n = require('./js/modules/i18n'); const Attachments = require('./app/attachments'); -const { locale } = config; -window.i18n = i18n.setup(locale, localeMessages); - -window.moment = require('moment'); - -window.moment.updateLocale(locale, { - relativeTime: { - s: window.i18n('timestamp_s'), - m: window.i18n('timestamp_m'), - h: window.i18n('timestamp_h'), - }, -}); -window.moment.locale(locale); - window.Signal = Signal.setup({ Attachments, userDataPath: app.getPath('userData'), @@ -418,6 +404,20 @@ window.seedNodeList = JSON.parse(config.seedNodeList); const { OnionAPI } = 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; + +window.moment.updateLocale(localeForMoment, { + relativeTime: { + s: window.i18n('timestamp_s'), + m: window.i18n('timestamp_m'), + h: window.i18n('timestamp_h'), + }, +}); +window.moment.locale(localeForMoment); + window.OnionAPI = OnionAPI; window.libsession = require('./ts/session');