fix: update lang toggle component

This commit is contained in:
2026-09-13 05:29:53 +05:00
parent abfcbbfac2
commit 1097186487
+14 -16
View File
@@ -1,24 +1,22 @@
<script lang="ts"> <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> </script>
<div class="lang" role="group" aria-label="Language"> <div class="lang" role="group" aria-label="Language">
<button {#each LOCALES as l (l)}
type="button" <button
class="lang-btn" type="button"
class:active={lang === "RU"} class="lang-btn"
onclick={() => (lang = "RU")} class:active={getLocale() === l}
> aria-pressed={getLocale() === l}
RU onclick={() => setLocale(l)}
</button> >
<button {LANG_LABELS[l]}
type="button" </button>
class="lang-btn" {/each}
class:active={lang === "EN"}
onclick={() => (lang = "EN")}>EN</button
>
</div> </div>
<style> <style>