From 862a5f9cdbbda522c608ea63c1e296e81f44de10 Mon Sep 17 00:00:00 2001
From: Ben Beltran <ben@nsovocal.com>
Date: Sat, 20 Jun 2020 16:20:31 +0200
Subject: Add internationalization support

---
 .../language_selector/language_selector.svelte     | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 app/components/language_selector/language_selector.svelte

(limited to 'app/components/language_selector/language_selector.svelte')

diff --git a/app/components/language_selector/language_selector.svelte b/app/components/language_selector/language_selector.svelte
new file mode 100644
index 0000000..67c0814
--- /dev/null
+++ b/app/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>
+
-- 
cgit 

