File: /var/www/fintechfuel/src/lib/translations/index.ts
import i18n from 'sveltekit-i18n';
import lang from './lang.json';
/** @type {import('sveltekit-i18n').Config} */
const config = {
translations: {
en: { lang },
pt: { lang },
},
loaders: [
{
locale: 'en',
key: '',
loader: async () => (await import('./en/en.json')).default,
},
{
locale: 'pt',
key: '',
loader: async () => (await import('./pt/pt.json')).default,
},
{
locale: 'en',
key: 'cookie',
routes: ['/cookie-policy'],
loader: async () => (await import('./en/cookie.json')).default,
},
{
locale: 'pt',
key: 'cookie',
routes: ['/cookie-policy'],
loader: async () => (await import('./pt/cookie.json')).default,
},
{
locale: 'en',
key: 'privacy',
routes: ['/privacy-policy'],
loader: async () => (await import('./en/privacy.json')).default,
},
{
locale: 'pt',
key: 'privacy',
routes: ['/privacy-policy'],
loader: async () => (await import('./pt/privacy.json')).default,
},
{
locale: 'en',
key: 'terms',
routes: ['/terms-and-conditions'],
loader: async () => (await import('./en/terms.json')).default,
},
{
locale: 'pt',
key: 'terms',
routes: ['/terms-and-conditions'],
loader: async () => (await import('./pt/terms.json')).default,
},
{
locale: 'en',
key: 'vulnerability',
routes: ['/vulnerability-disclosure-policy'],
loader: async () => (await import('./en/vulnerability.json')).default,
},
{
locale: 'pt',
key: 'vulnerability',
routes: ['/vulnerability-disclosure-policy'],
loader: async () => (await import('./pt/vulnerability.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();
}
});