File: /var/www/iq.affiliate/src/lib/translations/index.ts
import i18n from 'sveltekit-i18n';
import lang from './lang.json';
import enImg from '../../assets/images/langs/en.webp';
import ptImg from '../../assets/images/langs/pt.webp';
import ruImg from '../../assets/images/langs/ru.webp';
import itImg from '../../assets/images/langs/it.webp';
import deImg from '../../assets/images/langs/de.webp';
import esImg from '../../assets/images/langs/es.webp';
import zhImg from '../../assets/images/langs/zh.webp';
import svImg from '../../assets/images/langs/sv.webp';
import thImg from '../../assets/images/langs/th.webp';
import idImg from '../../assets/images/langs/id.webp';
/** @type {import('sveltekit-i18n').Config} */
const config = {
translations: {
en: { lang, image: enImg, },
pt: { lang, image: ptImg, },
ru: { lang, image: ruImg, },
it: { lang, image: itImg, },
de: { lang, image: deImg, },
es: { lang, image: esImg, },
zh: { lang, image: zhImg, },
sv: { lang, image: svImg, },
th: { lang, image: thImg, },
id: { lang, image: idImg, },
},
loaders: [
{
locale: 'en',
key: '',
loader: async () => (await import('./en/en.json')).default,
},
{
locale: 'pt',
key: '',
loader: async () => (await import('./pt/pt.json')).default,
},
{
locale: 'ru',
key: '',
loader: async () => (await import('./ru/ru.json')).default,
},
{
locale: 'it',
key: '',
loader: async () => (await import('./it/it.json')).default,
},
{
locale: 'de',
key: '',
loader: async () => (await import('./de/de.json')).default,
},
{
locale: 'es',
key: '',
loader: async () => (await import('./es/es.json')).default,
},
{
locale: 'zh',
key: '',
loader: async () => (await import('./zh/zh.json')).default,
},
{
locale: 'sv',
key: '',
loader: async () => (await import('./sv/sv.json')).default,
},
{
locale: 'th',
key: '',
loader: async () => (await import('./th/th.json')).default,
},
{
locale: 'id',
key: '',
loader: async () => (await import('./id/id.json')).default,
},
],
};
export const defaultLocale = 'en';
export const { t, locale, locales, loading, addTranslations, loadTranslations, translations, setRoute, setLocale } =
new i18n(config);
// Translations logs
loading.subscribe(async ($loading) => {
if ($loading) {
await loading.toPromise();
}
});