Improve tree shaking and dynamic loading, fix translations in production build. Moved i18n settings to the application's side.

This commit is contained in:
giancarlo
2024-04-13 12:43:02 +08:00
parent 31a8d68809
commit 7f11905fc1
28 changed files with 277 additions and 288 deletions

View File

@@ -3,15 +3,9 @@
*
*/
export async function i18nResolver(language: string, namespace: string) {
try {
const { default: data } = await import(
`../../public/locales/${language}/${namespace}.json`
const data = await import(
`../../public/locales/${language}/${namespace}.json`,
);
return data as Record<string, string>;
} catch (e) {
console.error('Could not load translation file', e);
return {} as Record<string, string>;
}
return data as Record<string, string>;
}