about summary refs log tree commit diff
path: root/src/locale/i18n.web.ts
diff options
context:
space:
mode:
authorEric Bailey <git@esb.lol>2023-12-12 12:42:11 -0600
committerGitHub <noreply@github.com>2023-12-12 12:42:11 -0600
commitc6ab6e8b8e81c1e2d72973a420cfea7aecc6e425 (patch)
treeab21ddf073883117b57a3d2e4c74e6b6e4b21311 /src/locale/i18n.web.ts
parentd82b1a104794eb237b898336fae0918dc1ec6753 (diff)
downloadvoidsky-c6ab6e8b8e81c1e2d72973a420cfea7aecc6e425.tar.zst
i18n settings improvements (#2184)
* Handle language selector

* Improve type safety

* Add a little more safety

* Update comment
Diffstat (limited to 'src/locale/i18n.web.ts')
-rw-r--r--src/locale/i18n.web.ts23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/locale/i18n.web.ts b/src/locale/i18n.web.ts
index bc484f303..54963836b 100644
--- a/src/locale/i18n.web.ts
+++ b/src/locale/i18n.web.ts
@@ -3,24 +3,23 @@ import {i18n} from '@lingui/core'
 
 import {useLanguagePrefs} from '#/state/preferences'
 import {sanitizeAppLanguageSetting} from '#/locale/helpers'
-
-export const locales = {
-  en: 'English',
-  hi: 'हिंदी',
-}
-export const defaultLocale = 'en'
+import {AppLanguage} from '#/locale/languages'
 
 /**
  * We do a dynamic import of just the catalog that we need
- * @param locale any locale string
  */
-export async function dynamicActivate(locale: string) {
+export async function dynamicActivate(locale: AppLanguage) {
   let mod: any
 
-  if (locale === 'hi') {
-    mod = await import(`./locales/hi/messages`)
-  } else {
-    mod = await import(`./locales/en/messages`)
+  switch (locale) {
+    case AppLanguage.hi: {
+      mod = await import(`./locales/hi/messages`)
+      break
+    }
+    default: {
+      mod = await import(`./locales/en/messages`)
+      break
+    }
   }
 
   i18n.load(locale, mod.messages)