From be3bd2cc6bf0dc40a4dd44fbfed95ed2bdf748be Mon Sep 17 00:00:00 2001 From: Jesse Rodriguez <wellpeng97@gmail.com> Date: Thu, 1 Aug 2024 20:25:17 +0800 Subject: [PATCH] fix: load user language profile --- packages/arex/package.json | 2 +- packages/arex/src/i18n/locales/cn/components.json | 11 +++++++++-- packages/arex/src/i18n/locales/en/components.json | 11 +++++++++-- .../SystemSetting/UserInterface/CompactSegmented.tsx | 7 ++++--- .../SystemSetting/UserInterface/ThemeSegmented.tsx | 9 +++++---- .../src/panes/SystemSetting/UserInterface/index.tsx | 2 +- packages/arex/src/store/useUserProfile.ts | 1 + 7 files changed, 30 insertions(+), 13 deletions(-) diff --git a/packages/arex/package.json b/packages/arex/package.json index 4e3bc1c07..16bbc7ec2 100644 --- a/packages/arex/package.json +++ b/packages/arex/package.json @@ -1,7 +1,7 @@ { "name": "arex", "private": true, - "version": "0.7.1", + "version": "0.7.2", "author": "arextest", "main": "dist-electron/main", "files": [ diff --git a/packages/arex/src/i18n/locales/cn/components.json b/packages/arex/src/i18n/locales/cn/components.json index 5c0dcb667..580aea406 100644 --- a/packages/arex/src/i18n/locales/cn/components.json +++ b/packages/arex/src/i18n/locales/cn/components.json @@ -424,11 +424,18 @@ "replayCallbackPlaceholder": "请输入回放回调地址", "startDownload": "下载即将开始...", "systemLogs": "系统日志", - "theme": "主题", + "theme": { + "dark": "黑暗", + "light": "明亮", + "system": "系统", + "theme": "主题" + }, "userInfo": "用户信息", "userInterface": "用户界面", "version": "版本", - "zen": "禅模式" + "zen": "禅模式", + "zoomIn": "放大", + "zoomOut": "缩小" }, "workSpace": { "accepted": "已接受", diff --git a/packages/arex/src/i18n/locales/en/components.json b/packages/arex/src/i18n/locales/en/components.json index 02382ff45..dba17fd61 100644 --- a/packages/arex/src/i18n/locales/en/components.json +++ b/packages/arex/src/i18n/locales/en/components.json @@ -426,11 +426,18 @@ "replayCallbackPlaceholder": "Please enter replay callback Url", "startDownload": "Download about to start...", "systemLogs": "System Logs", - "theme": "Theme", + "theme": { + "dark": "Dark", + "light": "Light", + "system": "System", + "theme": "Theme" + }, "userInfo": "User Info", "userInterface": "User Interface", "version": "Version", - "zen": "Zen mode" + "zen": "Zen mode", + "zoomIn": "Zoom In", + "zoomOut": "Zoom Out" }, "workSpace": { "accepted": "Accepted", diff --git a/packages/arex/src/panes/SystemSetting/UserInterface/CompactSegmented.tsx b/packages/arex/src/panes/SystemSetting/UserInterface/CompactSegmented.tsx index 16e89bc1c..80a650589 100644 --- a/packages/arex/src/panes/SystemSetting/UserInterface/CompactSegmented.tsx +++ b/packages/arex/src/panes/SystemSetting/UserInterface/CompactSegmented.tsx @@ -1,16 +1,17 @@ -import { Segmented } from '@arextest/arex-core'; +import { Segmented, useTranslation } from '@arextest/arex-core'; import { Tooltip } from 'antd'; import React, { FC } from 'react'; import { Icon } from '@/components'; const CompactSegmented: FC = (props) => { + const { t } = useTranslation(); return ( <Segmented options={[ { label: ( - <Tooltip title={'ZoomOut'}> + <Tooltip title={t('components:systemSetting.zoomOut')}> <Icon name='ZoomOut' /> </Tooltip> ), @@ -19,7 +20,7 @@ const CompactSegmented: FC = (props) => { }, { label: ( - <Tooltip title={'ZoomIn'}> + <Tooltip title={t('components:systemSetting.zoomIn')}> <Icon name='ZoomIn' /> </Tooltip> ), diff --git a/packages/arex/src/panes/SystemSetting/UserInterface/ThemeSegmented.tsx b/packages/arex/src/panes/SystemSetting/UserInterface/ThemeSegmented.tsx index 5cf0b8797..58b85fbe9 100644 --- a/packages/arex/src/panes/SystemSetting/UserInterface/ThemeSegmented.tsx +++ b/packages/arex/src/panes/SystemSetting/UserInterface/ThemeSegmented.tsx @@ -1,4 +1,4 @@ -import { Segmented } from '@arextest/arex-core'; +import { Segmented, useTranslation } from '@arextest/arex-core'; import { Tooltip } from 'antd'; import React, { FC } from 'react'; @@ -6,12 +6,13 @@ import { Icon } from '@/components'; import { Theme } from '@/constant'; const ThemeSegmented: FC = (props) => { + const { t } = useTranslation(); return ( <Segmented options={[ { label: ( - <Tooltip title={'Light'}> + <Tooltip title={t('components:systemSetting.theme.light')}> <Icon name='Sun' /> </Tooltip> ), @@ -19,7 +20,7 @@ const ThemeSegmented: FC = (props) => { }, { label: ( - <Tooltip title={'Dark'}> + <Tooltip title={t('components:systemSetting.theme.dark')}> <Icon name='MoonStar' /> </Tooltip> ), @@ -27,7 +28,7 @@ const ThemeSegmented: FC = (props) => { }, { label: ( - <Tooltip title={'System'}> + <Tooltip title={t('components:systemSetting.theme.system')}> <Icon name='Laptop' /> </Tooltip> ), diff --git a/packages/arex/src/panes/SystemSetting/UserInterface/index.tsx b/packages/arex/src/panes/SystemSetting/UserInterface/index.tsx index 508df08a5..1198402c6 100644 --- a/packages/arex/src/panes/SystemSetting/UserInterface/index.tsx +++ b/packages/arex/src/panes/SystemSetting/UserInterface/index.tsx @@ -119,7 +119,7 @@ const UserInterface = () => { <CompactSegmented /> </Form.Item> - <Form.Item label={t('systemSetting.theme')} name='theme'> + <Form.Item label={t('systemSetting.theme.theme')} name='theme'> <ThemeSegmented /> </Form.Item> diff --git a/packages/arex/src/store/useUserProfile.ts b/packages/arex/src/store/useUserProfile.ts index 72a8d1601..8897b2fd6 100644 --- a/packages/arex/src/store/useUserProfile.ts +++ b/packages/arex/src/store/useUserProfile.ts @@ -52,6 +52,7 @@ const useUserProfile = create<UserProfile & UserProfileAction>((set, get) => { window.message.error(e); } } + i18n.changeLanguage(profile?.language || 'en'); window.__locale__ = profile?.language || 'en'; profile && set(profile); }