fix: handle error and console.log

This commit is contained in:
Maël Gangloff
2024-08-27 20:02:38 +02:00
parent 46ac93df89
commit 0d8c57265e
2 changed files with 5 additions and 5 deletions

View File

@@ -5,10 +5,10 @@ export const regionNames = new Intl.DisplayNames([locale], {type: 'region'})
if (locale !== 'en') {
fetch(`/locales/${locale}.po.json`).then(response => {
if (!response.ok) throw new Error(`Failed to load translations for locale ${locale}`);
if (!response.ok) throw new Error(`Failed to load translations for locale ${locale}`)
response.json().then(translationsObj => {
addLocale(locale, translationsObj);
useLocale(locale);
addLocale(locale, translationsObj)
useLocale(locale)
})
})
}).catch(() => console.error(`Unable to retrieve translation file ${locale}.po.json`))
}