about summary refs log tree commit diff
path: root/src/locale/helpers.ts
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2024-06-10 11:37:14 -0700
committerGitHub <noreply@github.com>2024-06-10 20:37:14 +0200
commit59f49bef68500c1719ed44470121f553208edc85 (patch)
tree811063867718d9393fd66b90e13965ae6f9146fd /src/locale/helpers.ts
parent620ab887132855d447f0a328bf58989c8f3f3328 (diff)
downloadvoidsky-59f49bef68500c1719ed44470121f553208edc85.tar.zst
Override legacy language codes for indonesian, hebrew, and yiddish (#4461)
* Manually override incorrect 'in' to 'id' lang code

* Fix additional legacy language code issues
Diffstat (limited to 'src/locale/helpers.ts')
-rw-r--r--src/locale/helpers.ts19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/locale/helpers.ts b/src/locale/helpers.ts
index 24ab67893..cbaaf445a 100644
--- a/src/locale/helpers.ts
+++ b/src/locale/helpers.ts
@@ -116,7 +116,7 @@ export function sanitizeAppLanguageSetting(appLanguage: string): AppLanguage {
   const langs = appLanguage.split(',').filter(Boolean)
 
   for (const lang of langs) {
-    switch (lang) {
+    switch (fixLegacyLanguageCode(lang)) {
       case 'en':
         return AppLanguage.en
       case 'ca':
@@ -157,3 +157,20 @@ export function sanitizeAppLanguageSetting(appLanguage: string): AppLanguage {
   }
   return AppLanguage.en
 }
+
+export function fixLegacyLanguageCode(code: string | null): string | null {
+  // handle some legacy code conversions, see https://xml.coverpages.org/iso639a.html
+  if (code === 'in') {
+    // indonesian
+    return 'id'
+  }
+  if (code === 'iw') {
+    // hebrew
+    return 'he'
+  }
+  if (code === 'ji') {
+    // yiddish
+    return 'yi'
+  }
+  return code
+}