Skip to content

Commit

Permalink
fix: load user language profile
Browse files Browse the repository at this point in the history
  • Loading branch information
1pone committed Aug 1, 2024
1 parent c5a17f4 commit be3bd2c
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/arex/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "arex",
"private": true,
"version": "0.7.1",
"version": "0.7.2",
"author": "arextest",
"main": "dist-electron/main",
"files": [
Expand Down
11 changes: 9 additions & 2 deletions packages/arex/src/i18n/locales/cn/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -424,11 +424,18 @@
"replayCallbackPlaceholder": "请输入回放回调地址",
"startDownload": "下载即将开始...",
"systemLogs": "系统日志",
"theme": "主题",
"theme": {
"dark": "黑暗",
"light": "明亮",
"system": "系统",
"theme": "主题"
},
"userInfo": "用户信息",
"userInterface": "用户界面",
"version": "版本",
"zen": "禅模式"
"zen": "禅模式",
"zoomIn": "放大",
"zoomOut": "缩小"
},
"workSpace": {
"accepted": "已接受",
Expand Down
11 changes: 9 additions & 2 deletions packages/arex/src/i18n/locales/en/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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>
),
Expand All @@ -19,7 +20,7 @@ const CompactSegmented: FC = (props) => {
},
{
label: (
<Tooltip title={'ZoomIn'}>
<Tooltip title={t('components:systemSetting.zoomIn')}>
<Icon name='ZoomIn' />
</Tooltip>
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
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';
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>
),
value: Theme.light,
},
{
label: (
<Tooltip title={'Dark'}>
<Tooltip title={t('components:systemSetting.theme.dark')}>
<Icon name='MoonStar' />
</Tooltip>
),
value: Theme.dark,
},
{
label: (
<Tooltip title={'System'}>
<Tooltip title={t('components:systemSetting.theme.system')}>
<Icon name='Laptop' />
</Tooltip>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
1 change: 1 addition & 0 deletions packages/arex/src/store/useUserProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit be3bd2c

Please sign in to comment.