X-Git-Url: https://git.r.bdr.sh/rbdr/forum/blobdiff_plain/862a5f9cdbbda522c608ea63c1e296e81f44de10..bd8e98d7e24c4dbaee7db6ec7955f7c2f6d396a6:/src/components/language_selector/language_selector.svelte

diff --git a/src/components/language_selector/language_selector.svelte b/src/components/language_selector/language_selector.svelte
new file mode 100644
index 0000000..67c0814
--- /dev/null
+++ b/src/components/language_selector/language_selector.svelte
@@ -0,0 +1,28 @@
+<script>
+  import { locale, locales } from 'svelte-i18n';
+  import { getLangNameFromCode } from 'language-name-map';
+
+  $: namedLocales = $locales
+    .map((locale) => ({
+      code: locale,
+      ...getLangNameFromCode(locale)
+    }))
+    .sort((a, b) => a.native - b.native);
+
+  let selected = $locale;
+
+  $: {
+    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}
+</select>
+
+<style>
+</style>
+
