more components

This commit is contained in:
Henri
2025-11-24 19:25:14 +02:00
parent aae22efcaa
commit 8839dcdc93
3 changed files with 64 additions and 4 deletions

View File

@@ -5,13 +5,11 @@ const savedLang = typeof window !== 'undefined'
? localStorage.getItem('language') || 'est'
: 'est';
// Store for current language
export const currentLang = writable(savedLang);
// Store for translations
export const text = writable({});
// Load translations for a specific language
async function loadTranslations(lang) {
try {
const response = await fetch(`/locales/${lang}.json`);
@@ -22,10 +20,8 @@ async function loadTranslations(lang) {
}
}
// Initialize translations
loadTranslations(savedLang);
// Function to switch language
export function switchLang(lang) {
currentLang.set(lang);
loadTranslations(lang);