]> git.r.bdr.sh - rbdr/forum/blame - src/components/language_selector/language_selector.svelte
Add jest for testing
[rbdr/forum] / src / components / language_selector / language_selector.svelte
CommitLineData
862a5f9c 1<script>
58f7d521
RBR
2 import { locale, locales } from 'svelte-i18n';
3 import { getLangNameFromCode } from 'language-name-map';
862a5f9c 4
58f7d521
RBR
5 $: namedLocales = $locales
6 .map((code) => ({
7 code,
8 ...getLangNameFromCode(code)
9 }))
10 .sort((a, b) => a.native - b.native);
862a5f9c 11
58f7d521 12 let selected = $locale;
862a5f9c 13
58f7d521
RBR
14 $: {
15 console.log(`the current locale is ${selected}`);
16 locale.set(selected);
17 }
862a5f9c
BB
18</script>
19
20<select bind:value={selected}>
58f7d521
RBR
21 {#each namedLocales as namedLocale}
22 <option value={namedLocale.code}>{namedLocale.native}</option>
23 {/each}
862a5f9c
BB
24</select>
25
26<style>
27</style>