aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/LocaleSelector.svelte
blob: e5d1fdec24bc551dfc755c69b05fe0441d96bde5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<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=/`;
    console.log("settinglocale", value);
    $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>