aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/LocaleSelector.svelte
blob: b3930829d4bdfb69a4dd2e6d3dbb8834f929defd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<script>
  import { run } from "svelte/legacy";

  import { t, locale, locales } from "$lib/translations";
  let { style } = $props();
  let l = $state($locale);

  const handleChange = ({ currentTarget }) => {
    const { value } = currentTarget;
    document.cookie = `lang=${value}; path=/`;
    $locale = value;
    l = value;
  };
</script>

<select name="language" bind:value={l} onchange={handleChange}>
  {#each $locales as locale}
    <option value={locale}>{$t(`lang.${locale}`)}</option>
  {/each}
</select>