mirror of
https://github.com/Lapikud/lapikud.github.io.git
synced 2026-08-08 21:29:14 +00:00
more components
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user