]>
Commit | Line | Data |
---|---|---|
1 | <script> | |
2 | import { locale, locales } from 'svelte-i18n'; | |
3 | import { getLangNameFromCode } from 'language-name-map'; | |
4 | import { goto } from '$app/navigation'; | |
5 | ||
6 | $: namedLocales = $locales | |
7 | .map((code) => ({ | |
8 | code, | |
9 | ...getLangNameFromCode(code) | |
10 | })) | |
11 | .sort((a, b) => a.native - b.native); | |
12 | ||
13 | let selected = $locale; | |
14 | ||
15 | $: { | |
16 | locale.set(selected); | |
17 | } | |
18 | ||
19 | const navigateAway = function () { | |
20 | goto('/'); | |
21 | }; | |
22 | </script> | |
23 | ||
24 | <select bind:value={selected} on:change={navigateAway}> | |
25 | {#each namedLocales as namedLocale} | |
26 | <option value={namedLocale.code}>{namedLocale.native}</option> | |
27 | {/each} | |
28 | </select> | |
29 | ||
30 | <style> | |
31 | </style> |