Skip to content

Commit c022621

Browse files
authored
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
2 parents 8ba4dbb + 829cbb0 commit c022621

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

admin/src/index.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,20 @@ export default {
4949
bootstrap(app) {},
5050
async registerTrads({ locales }) {
5151
const importedTrads = await Promise.all(
52-
locales.map((locale) => {
53-
return import(
54-
/* webpackChunkName: "config-sync-translation-[request]" */ `./translations/${locale}.json`
55-
)
56-
.then(({ default: data }) => {
57-
return {
58-
data: prefixPluginTranslations(data, pluginId),
59-
locale,
60-
};
61-
})
62-
.catch(() => {
63-
return {
64-
data: {},
65-
locale,
66-
};
67-
});
52+
locales.map(async (locale) => {
53+
try {
54+
// eslint-disable-next-line import/no-dynamic-require, global-require
55+
const data = require(`./translations/${locale}.json`);
56+
return {
57+
data: prefixPluginTranslations(data, pluginId),
58+
locale,
59+
};
60+
} catch {
61+
return {
62+
data: {},
63+
locale,
64+
};
65+
}
6866
}),
6967
);
7068

0 commit comments

Comments
 (0)