import type { LocaleTranslations } from 'typesafe-i18n' ; import { i18nString as initI18nString , i18nObjectLoader , i18n as initI18n } from 'typesafe-i18n' ; import type { Translation , TranslationFunctions , Formatters , Locales } from './i18n-types' ; import type { LocaleDetector } from 'typesafe-i18n/detectors' ; import { detectLocale as detectLocaleFn } from 'typesafe-i18n/detectors' ; import { initFormatters } from './formatters' ; export const baseLocale = 'en' ; export const locales = [ 'da' , 'de' , 'en' , 'fr' , 'nl' ] ; import da from './da' ; import de from './de' ; import en from './en' ; import fr from './fr' ; import nl from './nl' ; const localeTranslations = { da , de , en : en as Translation , fr , nl , } ; export const getTranslationForLocale = ( locale ) => localeTranslations [ locale ] || localeTranslations [ baseLocale ] ; export const i18nObject = ( locale ) => i18nObjectLoader < Locales , Translation , TranslationFunctions , Formatters > ( locale , getTranslationForLocale , initFormatters ) ; export const i18n = ( ) => initI18n < Locales , Translation , TranslationFunctions , Formatters > ( getTranslationForLocale , initFormatters ) ; export const i18nString = ( locale ) => initI18nString < Locales , Formatters > ( locale , initFormatters ( locale ) ) ; export const detectLocale = ( ... detectors ) => detectLocaleFn < Locales > ( baseLocale , locales , ... detectors ) ;