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

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

  let l;
  run(() => {
    l = $locale;
  });

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

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