mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-01-25 21:11:59 +05:30
Allow the application to work without en.json file in dev environment
This commit is contained in:
parent
02e767b57c
commit
cd6c5fce4c
@ -72,6 +72,7 @@ class I18N {
|
|||||||
locale: string;
|
locale: string;
|
||||||
messages: Record<string, string>;
|
messages: Record<string, string>;
|
||||||
}> {
|
}> {
|
||||||
|
try {
|
||||||
const [{ default: messages }] = await Promise.all([
|
const [{ default: messages }] = await Promise.all([
|
||||||
import(/* webpackChunkName: "locale-[request]" */ `app/i18n/${locale}.json`),
|
import(/* webpackChunkName: "locale-[request]" */ `app/i18n/${locale}.json`),
|
||||||
intlPolyfill(locale),
|
intlPolyfill(locale),
|
||||||
@ -81,6 +82,25 @@ class I18N {
|
|||||||
locale,
|
locale,
|
||||||
messages,
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user