feat: add i18n with ttag

This commit is contained in:
Maël Gangloff
2024-07-28 15:36:22 +02:00
parent 05baaf911f
commit df0a93b8e6
13 changed files with 447 additions and 98 deletions

13
assets/i18n/index.ts Normal file
View File

@@ -0,0 +1,13 @@
import {addLocale, useLocale} from 'ttag'
const locale = navigator.language.split('-')[0];
if (locale !== 'en') {
fetch(`/locales/${locale}.po.json`).then(response => {
if (!response.ok) throw new Error(`Failed to load translations for locale ${locale}`);
response.json().then(translationsObj => {
addLocale(locale, translationsObj);
useLocale(locale);
})
})
}