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"> <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">
{#each LOCALES as l (l)}
<button <button
type="button" type="button"
class="lang-btn" class="lang-btn"
class:active={lang === "RU"} class:active={getLocale() === l}
onclick={() => (lang = "RU")} aria-pressed={getLocale() === l}
onclick={() => setLocale(l)}
> >
RU {LANG_LABELS[l]}
</button> </button>
<button {/each}
type="button"
class="lang-btn"
class:active={lang === "EN"}
onclick={() => (lang = "EN")}>EN</button
>
</div> </div>
<style> <style>