mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
15 lines
576 B
TypeScript
15 lines
576 B
TypeScript
import {addLocale, useLocale} from 'ttag'
|
|
|
|
const locale = navigator.language.split('-')[0]
|
|
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}`)
|
|
response.json().then(translationsObj => {
|
|
addLocale(locale, translationsObj)
|
|
useLocale(locale)
|
|
})
|
|
}).catch(() => console.error(`Unable to retrieve translation file ${locale}.po.json`))
|
|
}
|