about summary refs log tree commit diff
path: root/src/locale/helpers.ts
diff options
context:
space:
mode:
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
+}