lasthourcloud/src/lib/translations.ts

27 lines
651 B
TypeScript
Raw Normal View History

2022-04-02 16:15:00 +02:00
import i18n from 'sveltekit-i18n';
import lang from './lang.json';
/** @type {import('sveltekit-i18n').Config} */
export const config = {
2022-04-02 17:33:50 +02:00
fallbackLocale: 'en-US',
2022-04-02 16:15:00 +02:00
translations: {
2022-04-02 17:33:50 +02:00
'en-US': { lang },
'fr-FR': { lang }
2022-04-02 16:15:00 +02:00
},
loaders: [
{
2022-04-02 17:33:50 +02:00
locale: 'en-US',
2022-04-02 16:15:00 +02:00
key: '',
loader: async () => (await import('../../static/locales/en.json')).default
},
{
2022-04-02 17:33:50 +02:00
locale: 'fr-FR',
2022-04-02 16:15:00 +02:00
key: '',
loader: async () => (await import('../../static/locales/fr.json')).default
}
]
};
export const { t, loading, locales, locale, loadTranslations } = new i18n(config);
loading.subscribe(($loading) => $loading && console.log('Loading translations...'));