Change the way to load i18n (go throw cookie)

This commit is contained in:
Restray
2022-04-02 20:25:24 +02:00
parent 943300509b
commit a3241516cb
11 changed files with 142 additions and 118 deletions

28
src/lib/translations.ts Normal file
View File

@@ -0,0 +1,28 @@
import i18n from 'sveltekit-i18n';
import lang from './lang.json';
/** @type {import('sveltekit-i18n').Config} */
const config = {
defaultLocale: 'en',
fallbackLocale: 'en',
translations: {
en: { lang },
fr: { lang }
},
loaders: [
{
locale: 'en',
key: '',
loader: async () => (await import('../../static/locales/en.json')).default
},
{
locale: 'fr',
key: '',
loader: async () => (await import('../../static/locales/fr.json')).default
}
]
};
export const { t, locale, locales, loading, loadTranslations } = new i18n(config);
loading.subscribe(($loading) => $loading && console.log('Loading translations...'));