Merge pull request #150 from michaelrazmgah/feature/fix-issue-where-locale-is-not-found

fix: Fixing bug where Strapi UI is crashing when no locale is found
pull/153/head 2.1.0
Boaz Poolman 2024-10-18 22:00:59 +02:00 committed by GitHub
commit c02262184f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 16 deletions

View File

@ -49,22 +49,20 @@ export default {
bootstrap(app) {}, bootstrap(app) {},
async registerTrads({ locales }) { async registerTrads({ locales }) {
const importedTrads = await Promise.all( const importedTrads = await Promise.all(
locales.map((locale) => { locales.map(async (locale) => {
return import( try {
/* webpackChunkName: "config-sync-translation-[request]" */ `./translations/${locale}.json` // eslint-disable-next-line import/no-dynamic-require, global-require
) const data = require(`./translations/${locale}.json`);
.then(({ default: data }) => { return {
return { data: prefixPluginTranslations(data, pluginId),
data: prefixPluginTranslations(data, pluginId), locale,
locale, };
}; } catch {
}) return {
.catch(() => { data: {},
return { locale,
data: {}, };
locale, }
};
});
}), }),
); );