mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-01-11 06:12:42 +05:30
Allow the application to work without en.json file in dev environment
This commit is contained in:
parent
02e767b57c
commit
cd6c5fce4c
@ -72,15 +72,35 @@ class I18N {
|
||||
locale: string;
|
||||
messages: Record<string, string>;
|
||||
}> {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user