+1
This commit is contained in:
parent
b77725b9f9
commit
8b936603cc
3 changed files with 86 additions and 19 deletions
|
|
@ -37,8 +37,12 @@ export const I18nProvider = ({ children, initialLanguage }: I18nProviderProps) =
|
|||
await Promise.all(
|
||||
namespaces.map(async (ns) => {
|
||||
try {
|
||||
const data = await import(`../../../public/locales/${lang}/${ns}.json`);
|
||||
newTranslations[lang][ns] = data.default || data;
|
||||
const res = await fetch(`/locales/${lang}/${ns}.json`);
|
||||
if (!res.ok) {
|
||||
throw new Error(`HTTP ${res.status}`);
|
||||
}
|
||||
const data = await res.json();
|
||||
newTranslations[lang][ns] = data;
|
||||
} catch (e) {
|
||||
console.error(`Failed to load ${lang}/${ns} translations`, e);
|
||||
newTranslations[lang][ns] = {};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue