From a7cf03c192470cbab13edeb1aec99e0c66dede10 Mon Sep 17 00:00:00 2001
From: Ruben Beltran del Rio <ruben@unlimited.pizza>
Date: Sun, 1 May 2022 00:56:06 +0200
Subject: Update / use typescript

---
 .../language_selector/language_selector.svelte     | 26 ++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 src/lib/components/language_selector/language_selector.svelte

(limited to 'src/lib/components/language_selector/language_selector.svelte')

diff --git a/src/lib/components/language_selector/language_selector.svelte b/src/lib/components/language_selector/language_selector.svelte
new file mode 100644
index 0000000..64a4ef9
--- /dev/null
+++ b/src/lib/components/language_selector/language_selector.svelte
@@ -0,0 +1,26 @@
+<script lang="ts">
+	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);
+
+  let selected = $locale
+
+	$: {
+	  locale.set(selected);
+	}
+</script>
+
+<select bind:value={selected}>
+	{#each namedLocales as namedLocale}
+		<option value={namedLocale.code}>{namedLocale.native}</option>
+	{/each}
+</select>
+
+<style>
+</style>
-- 
cgit 

