浏览代码

enhance(i18n): normalize language codes and update locale handling

charlie 5 天之前
父节点
当前提交
c041457668
共有 2 个文件被更改,包括 7 次插入4 次删除
  1. 2 2
      packages/ui/src/amplify/lang.ts
  2. 5 2
      src/main/frontend/components/theme.cljs

+ 2 - 2
packages/ui/src/amplify/lang.ts

@@ -2,7 +2,7 @@ export default {
   'en': {
     'CODE_ON_THE_WAY_TIP': 'Your code is on the way. To log in, enter the code we sent you. It may take a minute to arrive.',
   },
-  'zh-CN': {
+  'zh-cn': {
     'CODE_ON_THE_WAY_TIP': '验证码已发送。请输入我们发送给您的验证码以登录。可能需要一分钟才能收到。',
     'Sign in to your account': '登录到您的账户',
     'Email': '电子邮箱',
@@ -28,7 +28,7 @@ export default {
     'Back to login': '返回登录',
     'Enter your email': '请输入您的电子邮箱'
   },
-  'zh-Han': {
+  'zh-hant': {
     'CODE_ON_THE_WAY_TIP': '驗證碼已發送。請輸入我們發送給您的驗證碼以登入。可能需要一分鐘才能收到。',
     'Sign in to your account': '登入到您的帳戶',
     'Email': '電子郵箱',

+ 5 - 2
src/main/frontend/components/theme.cljs

@@ -1,5 +1,6 @@
 (ns frontend.components.theme
-  (:require [electron.ipc :as ipc]
+  (:require [clojure.string :as string]
+            [electron.ipc :as ipc]
             [frontend.components.settings :as settings]
             [frontend.config :as config]
             [frontend.context.i18n :refer [t]]
@@ -68,7 +69,9 @@
 
     (hooks/use-effect!
      #(let [doc js/document.documentElement]
-        (.setAttribute doc "lang" preferred-language)))
+        (.setAttribute doc "lang" preferred-language)
+        (some-> preferred-language (string/lower-case) (js/LSI18N.setLocale)))
+     [preferred-language])
 
     (hooks/use-effect!
      #(js/setTimeout