about summary refs log tree commit diff
path: root/src/locale/helpers.ts
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2024-01-12 10:20:17 -0800
committerGitHub <noreply@github.com>2024-01-12 10:20:17 -0800
commit95d771b3a559caa4ebd7e800d46c6a003744d92b (patch)
tree1f779275ffe6c14637fffb0ea9c5a4a5c404c886 /src/locale/helpers.ts
parent998ee2998657e82395fe4462809c376ffbd03ed8 (diff)
downloadvoidsky-95d771b3a559caa4ebd7e800d46c6a003744d92b.tar.zst
Suggest post language correction (#2486)
* feat: suggested language

* fix: wording correction

* Factor out SuggestedLanguage into a separate component

* Tighten the language-suggestion confidence to avoid false positives

* Tweak the copy and UI

* Add function fallbacks for safari

---------

Co-authored-by: Mary <pineapplecreamcheese@skiff.com>
Diffstat (limited to 'src/locale/helpers.ts')
-rw-r--r--src/locale/helpers.ts8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/locale/helpers.ts b/src/locale/helpers.ts
index 433dbaec6..8b3bf5f3d 100644
--- a/src/locale/helpers.ts
+++ b/src/locale/helpers.ts
@@ -22,6 +22,14 @@ export function code3ToCode2(lang: string): string {
   return lang
 }
 
+export function code3ToCode2Strict(lang: string): string | undefined {
+  if (lang.length === 3) {
+    return LANGUAGES_MAP_CODE3[lang]?.code2
+  }
+
+  return undefined
+}
+
 export function codeToLanguageName(lang: string): string {
   const lang2 = code3ToCode2(lang)
   return LANGUAGES_MAP_CODE2[lang2]?.name || lang