web: i18n system & navbar translations
dynamic page language and language dropdown!! finally!!
This commit is contained in:
48
web/src/lib/i18n/translations.ts
Normal file
48
web/src/lib/i18n/translations.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import i18n from 'sveltekit-i18n';
|
||||
import type { Config } from 'sveltekit-i18n';
|
||||
|
||||
import languages from '$i18n/languages.json';
|
||||
|
||||
export const defaultLocale = 'en';
|
||||
|
||||
export const config: Config = {
|
||||
translations: {
|
||||
en: { languages },
|
||||
ru: { languages },
|
||||
},
|
||||
loaders: [
|
||||
{
|
||||
locale: 'en',
|
||||
key: 'tabs',
|
||||
loader: async () => (
|
||||
await import(`$i18n/en/tabs.json`)
|
||||
).default,
|
||||
},
|
||||
{
|
||||
locale: 'en',
|
||||
key: 'a11y.tabs',
|
||||
loader: async () => (
|
||||
await import(`$i18n/en/a11y/tabs.json`)
|
||||
).default,
|
||||
},
|
||||
{
|
||||
locale: 'ru',
|
||||
key: 'tabs',
|
||||
loader: async () => (
|
||||
await import(`$i18n/ru/tabs.json`)
|
||||
).default,
|
||||
},
|
||||
{
|
||||
locale: 'ru',
|
||||
key: 'a11y.tabs',
|
||||
loader: async () => (
|
||||
await import(`$i18n/ru/a11y/tabs.json`)
|
||||
).default,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const {
|
||||
t, loading, locales, locale, translations,
|
||||
loadTranslations, addTranslations, setLocale, setRoute
|
||||
} = new i18n(config);
|
||||
Reference in New Issue
Block a user