* chore: migration to SvelteKit 2 * stage 1: migrate to svelte 5 and fix rerendering issues * stage 2: fix more $: reactivity across dashboard * fix merge conflicts * chore: migrate code in main to svelte 5 * chore: update preventDefault * chore: simplify tsconfig and remove unused mobileMenuRef in MobileMenu.svelte * chore: enforce .ts across dashboard * rename from classroomio-com to website * stage-3: Replace carbon icon svelte with lucide icon * update lock file * chore: finish icon replacement * fix: settings and setup page multiple rerender * stage 3: More icon and rerendering fixes * feat: setup drizzle and better auth * fix: onboarding validation error showing translation key #586 (#593) * fix: onboarding validation error showing translation key #586 * fix: remove debug log for profile update errors * chore: add a clean command * fix: remove message from email verification response
99 lines
2.3 KiB
TypeScript
99 lines
2.3 KiB
TypeScript
import { LOCALE } from '$lib/utils/types';
|
|
import i18n from '@sveltekit-i18n/base';
|
|
import parser from '@sveltekit-i18n/parser-icu';
|
|
import { writable } from 'svelte/store';
|
|
|
|
export const config = {
|
|
parser: parser(),
|
|
loaders: [
|
|
{
|
|
locale: 'en',
|
|
key: '',
|
|
loader: async () => (await import('../translations/en.json')).default
|
|
},
|
|
{
|
|
locale: 'hi',
|
|
key: '',
|
|
loader: async () => (await import('../translations/hi.json')).default
|
|
},
|
|
{
|
|
locale: 'fr',
|
|
key: '',
|
|
loader: async () => (await import('../translations/fr.json')).default
|
|
},
|
|
{
|
|
locale: 'pl',
|
|
key: '',
|
|
loader: async () => (await import('../translations/pl.json')).default
|
|
},
|
|
{
|
|
locale: 'pt',
|
|
key: '',
|
|
loader: async () => (await import('../translations/pt.json')).default
|
|
},
|
|
{
|
|
locale: 'de',
|
|
key: '',
|
|
loader: async () => (await import('../translations/de.json')).default
|
|
},
|
|
{
|
|
locale: 'vi',
|
|
key: '',
|
|
loader: async () => (await import('../translations/vi.json')).default
|
|
},
|
|
{
|
|
locale: 'ru',
|
|
key: '',
|
|
loader: async () => (await import('../translations/ru.json')).default
|
|
},
|
|
{
|
|
locale: 'es',
|
|
key: '',
|
|
loader: async () => (await import('../translations/es.json')).default
|
|
},
|
|
{
|
|
locale: 'da',
|
|
key: '',
|
|
loader: async () => (await import('../translations/da.json')).default
|
|
}
|
|
]
|
|
};
|
|
|
|
export const { t, loading, locales, locale, initialized, translations, loadTranslations } = new i18n(config);
|
|
|
|
export const selectedLocale = writable<string>('en');
|
|
|
|
// Translations logs
|
|
loading.subscribe(async ($loading) => {
|
|
if ($loading) {
|
|
console.log('Loading translations...');
|
|
|
|
await loading.toPromise();
|
|
}
|
|
});
|
|
|
|
export function handleLocaleChange(newLocale: LOCALE) {
|
|
if (!newLocale) {
|
|
return;
|
|
}
|
|
|
|
locale.set(newLocale);
|
|
|
|
selectedLocale.set(newLocale);
|
|
}
|
|
|
|
export function lessonFallbackNote(note: string, translation: Record<LOCALE, string>, locale: LOCALE) {
|
|
if (!translation) {
|
|
return note;
|
|
}
|
|
|
|
const content = translation[locale];
|
|
|
|
// if locale is english and no translated content for english but note exists
|
|
if (locale === LOCALE.EN && !content && note?.length) {
|
|
return note;
|
|
}
|
|
|
|
return content;
|
|
}
|