]> git.r.bdr.sh - rbdr/forum/blame - src/lib/components/language_selector/language_selector.svelte
Update eslint
[rbdr/forum] / src / lib / components / language_selector / language_selector.svelte
CommitLineData
a7cf03c1 1<script lang="ts">
58f7d521
RBR
2 import { locale, locales } from 'svelte-i18n';
3 import { getLangNameFromCode } from 'language-name-map';
862a5f9c 4
58f7d521 5 $: namedLocales = $locales
cac85db0
RBR
6 .map((code) => ({
7 code,
8 ...getLangNameFromCode(code)
9 }))
be1ce532
RBR
10 .sort((a, b) => {
11 if (a.native > b.native) {
12 return 1;
13 }
14
15 if (a.native < b.native) {
16 return -1;
17 }
18
19 return 0;
20 });
862a5f9c 21
cac85db0 22 let selected = $locale;
862a5f9c 23
58f7d521 24 $: {
cac85db0 25 locale.set(selected);
58f7d521 26 }
862a5f9c
BB
27</script>
28
29<select bind:value={selected}>
58f7d521
RBR
30 {#each namedLocales as namedLocale}
31 <option value={namedLocale.code}>{namedLocale.native}</option>
32 {/each}
862a5f9c
BB
33</select>
34
35<style>
36</style>