mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
feat: add i18n with ttag
This commit is contained in:
13
assets/i18n/index.ts
Normal file
13
assets/i18n/index.ts
Normal 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);
|
||||
})
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user