<script>
- import { locale, locales } from 'svelte-i18n';
- import { getLangNameFromCode } from 'language-name-map';
+ import { locale, locales } from 'svelte-i18n';
+ import { getLangNameFromCode } from 'language-name-map';
- $: namedLocales = $locales
- .map((code) => ({
- code,
- ...getLangNameFromCode(code)
- }))
- .sort((a, b) => a.native - b.native);
+ $: namedLocales = $locales
+ .map((code) => ({
+ code,
+ ...getLangNameFromCode(code)
+ }))
+ .sort((a, b) => a.native - b.native);
- let selected = $locale;
+ let selected = $locale;
- $: {
- console.log(`the current locale is ${selected}`);
- locale.set(selected);
- }
+ $: {
+ console.log(`the current locale is ${selected}`);
+ locale.set(selected);
+ }
</script>
<select bind:value={selected}>
- {#each namedLocales as namedLocale}
- <option value="{ namedLocale.code }">{ namedLocale.native }</option>
- {/each}
+ {#each namedLocales as namedLocale}
+ <option value={namedLocale.code}>{namedLocale.native}</option>
+ {/each}
</select>
<style>
</style>
-