From 38431710cfb1cc1ffd7297085d069be1328f083b Mon Sep 17 00:00:00 2001
From: Ruben Beltran del Rio <ruben@unlimited.pizza>
Date: Sun, 29 Aug 2021 21:49:37 +0200
Subject: Add project

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

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

diff --git a/src/lib/components/language_selector.svelte b/src/lib/components/language_selector.svelte
new file mode 100644
index 0000000..e8d0c44
--- /dev/null
+++ b/src/lib/components/language_selector.svelte
@@ -0,0 +1,31 @@
+<script>
+	import { locale, locales } from 'svelte-i18n';
+	import { getLangNameFromCode } from 'language-name-map';
+  import { goto } from '$app/navigation';
+
+	$: namedLocales = $locales
+	  .map((code) => ({
+	    code,
+	    ...getLangNameFromCode(code)
+	  }))
+	  .sort((a, b) => a.native - b.native);
+
+	let selected = $locale;
+
+	$: {
+	  locale.set(selected);
+	}
+
+  const navigateAway = function () {
+    goto('/');
+  };
+</script>
+
+<select bind:value={selected} on:change={navigateAway}>
+	{#each namedLocales as namedLocale}
+		<option value={namedLocale.code}>{namedLocale.native}</option>
+	{/each}
+</select>
+
+<style>
+</style>
-- 
cgit 

