fix: update lang toggle component

This commit is contained in:
2026-09-13 05:29:53 +05:00
parent abfcbbfac2
commit 1097186487
+9 -11
View File
@@ -1,24 +1,22 @@
<script lang="ts">
let lang = $state("RU");
import { LOCALES, type Locale } from "$lib/i18n/dict";
import { getLocale, setLocale } from "$lib/i18n/locale.svelte";
// TODO: change to sectioned dual buttons
const LANG_LABELS: Record<Locale, string> = { ru: "RU", en: "EN" };
</script>
<div class="lang" role="group" aria-label="Language">
{#each LOCALES as l (l)}
<button
type="button"
class="lang-btn"
class:active={lang === "RU"}
onclick={() => (lang = "RU")}
class:active={getLocale() === l}
aria-pressed={getLocale() === l}
onclick={() => setLocale(l)}
>
RU
{LANG_LABELS[l]}
</button>
<button
type="button"
class="lang-btn"
class:active={lang === "EN"}
onclick={() => (lang = "EN")}>EN</button
>
{/each}
</div>
<style>