14 lines
419 B
TypeScript
Raw Normal View History

2024-07-28 15:36:22 +02:00
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);
})
})
}