aboutsummaryrefslogtreecommitdiffstats
path: root/code/app/src/lib/components/locale-switcher.svelte
diff options
context:
space:
mode:
Diffstat (limited to 'code/app/src/lib/components/locale-switcher.svelte')
-rw-r--r--code/app/src/lib/components/locale-switcher.svelte4
1 files changed, 3 insertions, 1 deletions
diff --git a/code/app/src/lib/components/locale-switcher.svelte b/code/app/src/lib/components/locale-switcher.svelte
index b0230f8..3681bf5 100644
--- a/code/app/src/lib/components/locale-switcher.svelte
+++ b/code/app/src/lib/components/locale-switcher.svelte
@@ -11,6 +11,7 @@
export let _pwKey: string | undefined = undefined;
export let tabindex: number | undefined = undefined;
+ let currentLocale = Cookies.get(CookieNames.locale);
async function switch_locale(newLocale: Locales) {
if (!newLocale || $locale === newLocale) return;
@@ -18,6 +19,7 @@
setLocale(newLocale);
document.querySelector("html")?.setAttribute("lang", newLocale);
Cookies.set(CookieNames.locale, newLocale);
+ currentLocale = newLocale;
console.log("Switched to: " + newLocale);
}
@@ -49,6 +51,6 @@
class="mt-1 mr-1 block border-none py-2 pl-3 pr-10 text-base rounded-md right-0 absolute focus:outline-none focus:ring-teal-500 sm:text-sm"
>
{#each locales as aLocale}
- <option value={aLocale}>{get_locale_name(aLocale)}</option>
+ <option value={aLocale} selected={aLocale === currentLocale}>{get_locale_name(aLocale)}</option>
{/each}
</select>