diff --git a/packages/app/services/i18n/i18n.ts b/packages/app/services/i18n/i18n.ts index eb39612..2901d3f 100644 --- a/packages/app/services/i18n/i18n.ts +++ b/packages/app/services/i18n/i18n.ts @@ -72,15 +72,35 @@ class I18N { locale: string; messages: Record; }> { - const [{ default: messages }] = await Promise.all([ - import(/* webpackChunkName: "locale-[request]" */ `app/i18n/${locale}.json`), - intlPolyfill(locale), - ]); + try { + const [{ default: messages }] = await Promise.all([ + import(/* webpackChunkName: "locale-[request]" */ `app/i18n/${locale}.json`), + intlPolyfill(locale), + ]); - return { - locale, - messages, - }; + return { + locale, + messages, + }; + } catch (err) { + if (process.env.NODE_ENV !== 'production') { + if (err.message === "Cannot find module './en.json'") { + console.warn( + [ + "Locales module for the source language isn't exists.", + 'You may generate this file by running yarn i18n:extract command.', + 'Until then, defaultMessages will be used for displaying on the site.', + ].join(' '), + ); + } else { + console.error(err); + } + + return { locale, messages: {} }; + } + + throw err; + } } }