Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

feat: enhance language support by loading translations based on user settings

Tonhof3fa7d7e6f37
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index aea19e4a..6125e751 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -6,7 +6,7 @@
import { getActiveCount } from "$lib/stores/download-store.svelte";
import { loadSettings } from "$lib/stores/settings-store.svelte";
import Toast from "$components/toast/Toast.svelte";
- import { t } from "$lib/i18n";
+ import { t, locale, loadTranslations, defaultLocale } from "$lib/i18n";
import type { Snippet } from "svelte";
let activeCount = $derived(getActiveCount());
@@ -16,7 +16,13 @@
onMount(() => {
let cleanup: (() => void) | undefined;
initDownloadListener().then((fn) => (cleanup = fn));
- loadSettings();
+ loadSettings().then(async (settings) => {
+ const lang = settings.appearance.language;
+ if (lang && lang !== defaultLocale) {
+ await loadTranslations(lang, window.location.pathname);
+ locale.set(lang);
+ }
+ });
return () => cleanup?.();
});