diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-12-05 07:02:57 +0100 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-12-05 07:02:57 +0100 |
| commit | 93efdbc1e7def640ec03f92a7fb447d33133c7ae (patch) | |
| tree | 799c78d21981cc344cdc7a643121009ea730dd4f /code/app/src/lib/components/locale-switcher.svelte | |
| parent | 415914ddec430192f364296c2b82fcf6d82d88b9 (diff) | |
| download | greatoffice-93efdbc1e7def640ec03f92a7fb447d33133c7ae.tar.xz greatoffice-93efdbc1e7def640ec03f92a7fb447d33133c7ae.zip | |
feat: Show active locale in select
Diffstat (limited to 'code/app/src/lib/components/locale-switcher.svelte')
| -rw-r--r-- | code/app/src/lib/components/locale-switcher.svelte | 4 |
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> |
