Skip to content

Commit 3e734eb

Browse files
committed
fix:修改国际化配置
1 parent aa1c35a commit 3e734eb

File tree

10 files changed

+774
-51
lines changed

10 files changed

+774
-51
lines changed

packages/react-steps/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"styled-components": "~5.3.5"
4646
},
4747
"dependencies": {
48-
"@uiw/icons": "^2.6.7",
48+
"@uiw/icons": "2.6.1",
4949
"@uiw/utils": "^4.21.2"
5050
}
5151
}

website/.kktrc.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Configuration } from 'webpack';
1+
import webpack, { Configuration } from 'webpack';
22
import { LoaderConfOptions } from 'kkt';
33
import path from 'path';
44
import lessModules from '@kkt/less-modules';
@@ -7,6 +7,7 @@ import scopePluginOptions from '@kkt/scope-plugin-options';
77
import { mdCodeModulesLoader } from 'markdown-react-code-preview-loader';
88

99
export default (conf: Configuration, env: 'development' | 'production', options: LoaderConfOptions) => {
10+
let LOADPATH = env === 'production' ? '/uiw' : '';
1011
conf = lessModules(conf, env, options);
1112
conf = rawModules(conf, env, { ...options });
1213
conf = scopePluginOptions(conf, env, {
@@ -19,6 +20,11 @@ export default (conf: Configuration, env: 'development' | 'production', options:
1920
conf.module!.exprContextRecursive = false;
2021

2122
conf = mdCodeModulesLoader(conf, ['jsx', 'js', 'tsx']);
23+
conf.plugins!.push(
24+
new webpack.DefinePlugin({
25+
LOADPATH: JSON.stringify(LOADPATH),
26+
}),
27+
);
2228

2329
if (env === 'production') {
2430
conf.optimization = {

website/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
"@uiw/react-codepen": "~1.0.2",
4646
"i18next-browser-languagedetector": "^6.1.4",
4747
"uiw": "^4.21.3",
48-
"react-code-preview-layout": "~1.0.0"
48+
"react-code-preview-layout": "~1.0.0",
49+
"i18next-http-backend": "~1.4.1"
4950
},
5051
"devDependencies": {
5152
"@kkt/less-modules": "~7.1.1",
@@ -78,4 +79,4 @@
7879
"last 1 safari version"
7980
]
8081
}
81-
}
82+
}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
{
2+
"menu": {
3+
"divider": {
4+
"basic": "Basic",
5+
"layout": "Layout",
6+
"form": "form",
7+
"date": "Time Calendar",
8+
"data": "Data display",
9+
"nav": "Navigation",
10+
"feedback": "Feedback",
11+
"map": "Map",
12+
"editor": "Editor",
13+
"other": "other"
14+
},
15+
"/guide": "Guide",
16+
"/guideChildren": {
17+
"quick-start": "Quick-start",
18+
"import": "Load on demand",
19+
"create-react-app": "Use in create-react-app",
20+
"kkt": "Use in kkt",
21+
"vscode": "VSCode Plugin",
22+
"docs": "Document Edit Preview",
23+
"releases": "Changelog",
24+
"recommendation": "Community Featured Components",
25+
"awesome-uikit": "Awesome UIKit",
26+
"awesome-react-components": "Awesome React Components"
27+
},
28+
"/components": "Components",
29+
"/componentsChildren": {
30+
"colors": "Color Colors",
31+
"reset-css": "Reset CSS",
32+
"icon": "Icon icon",
33+
"button": "Button button",
34+
"divider": "Divider dividing line",
35+
"grid": "Grid delete grid",
36+
"layout": "Layout",
37+
"Split": "Split Panel Split",
38+
"form": "Form Form",
39+
"radio": "Radio radio",
40+
"checkbox": "Checkbox",
41+
"cascader": "Cascader Cascade Selection",
42+
"input": "Input input box",
43+
"file-input": "FileInput upload input box",
44+
"pin-code": "PinCode PIN code",
45+
"rate": "Rate Rating",
46+
"switch": "Switch switch",
47+
"select": "Select selector",
48+
"search-select": "SearchSelect search selector",
49+
"search-tree": "SearchTree search tree control",
50+
"slider": "Slider input bar",
51+
"tree-checked": "TreeChecked tree selection control",
52+
"transfer": "Transfer Shuttle Box",
53+
"textarea": "Textarea multi-line text input box",
54+
"react-color": "Color Color Picker",
55+
"calendar": "Calendar Calendar",
56+
"date-picker": "DatePicker date picker",
57+
"date-input": "DateInput date input box",
58+
"time-picker": "TimePicker time input box",
59+
"month-picker": "MonthPicker month picker",
60+
"formatter": "formatter time formatter",
61+
"avatar": "Avatar Avatar",
62+
"badge": "Badge marker",
63+
"card": "Card Card",
64+
"carousel": "Carousel Carousel",
65+
"collapse": "Collapse Collapse Panel",
66+
"descriptions": "Descriptions description list",
67+
"tag": "Tag tag",
68+
"tree": "Tree tree control",
69+
"table": "Table table",
70+
"progress": "Progress progress bar",
71+
"list": "List list",
72+
"auto-link": "AutoLink text hyperlink",
73+
"empty": "Empty empty state",
74+
"react-heat-map": "HeatMap Calendar Heatmap",
75+
"react-markdown-preview": "Markdown Preview",
76+
"affix": "Affix pin",
77+
"breadcrumb": "Breadcrumb",
78+
"dropdown": "Dropdown dropdown menu",
79+
"menu": "Menu menu",
80+
"pagination": "Pagination Pagination",
81+
"steps": "Steps step bar",
82+
"tabs": "Tabs",
83+
"overlay": "Overlay base popup",
84+
"overlay-trigger": "OverlayTrigger base popup trigger",
85+
"alert": "Alert confirmation dialog",
86+
"drawer": "Drawer drawer",
87+
"modal": "Modal modal dialog",
88+
"message": "Message Warning",
89+
"loader": "Loader loader",
90+
"notify": "Notify message notification",
91+
"popover": "Popover Bubble Card",
92+
"tooltip": "Tooltip text hint",
93+
"react-amap": "AMap Gaode Map",
94+
"react-baidu-map": "BaiduMap Baidu Map",
95+
"react-textarea-code-editor": "Textarea CodeEditor",
96+
"react-md-editor": "MDEditor editor",
97+
"react-markdown-editor": "Markdown Editor",
98+
"react-code-preview": "CodePreview JS edit preview",
99+
"react-codemirror": "Codemirror code editor",
100+
"react-monacoeditor": "MonacoEditor code editor",
101+
"back-top": "BackTop back to top",
102+
"copy-to-clipboard": "CopyToClipboard",
103+
"portal": "Portal Portal",
104+
"react-github-corners": "Github Corners",
105+
"react-only-when": "Only When",
106+
"react-run-web": "Run Web"
107+
},
108+
"/extensions": "Extensions",
109+
"issue": "Submit an issue",
110+
"github": "Github",
111+
"gitee": "Gitee"
112+
},
113+
"footer": {
114+
"greeting": "Making a mistake or want to contribute to the documentation?",
115+
"greetLinkText": "Edit this page on Github!",
116+
"issues": "Feedback Suggestions",
117+
"bug": "Submit a bug",
118+
"github": "Github",
119+
"kkt": "kkt",
120+
"kkt_ssr": "@kkt/ssr",
121+
"io": "Domestic Mirror"
122+
}
123+
}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
{
2+
"menu": {
3+
"divider": {
4+
"basic": "基本",
5+
"layout": "布局",
6+
"form": "表单",
7+
"date": "时间日历",
8+
"data": "数据显示",
9+
"nav": "导航",
10+
"feedback": "反馈",
11+
"map": "地图",
12+
"editor": "编辑器",
13+
"other": "其它"
14+
},
15+
"/guide": "指南",
16+
"/guideChildren": {
17+
"quick-start": "快速开始",
18+
"import": "按需加载",
19+
"create-react-app": "在 create-react-app 中使用",
20+
"kkt": "在 kkt 中使用",
21+
"vscode": "VSCode 插件",
22+
"docs": "文档编辑预览",
23+
"releases": "更新日志",
24+
"recommendation": "社区精选组件",
25+
"awesome-uikit": "Awesome UIKit",
26+
"awesome-react-components": "Awesome React Components"
27+
},
28+
"/components": "组件",
29+
"/componentsChildren": {
30+
"colors": "Color 颜色",
31+
"reset-css": "Reset CSS",
32+
"icon": "Icon 图标",
33+
"button": "Button 按钮",
34+
"divider": "Divider 分割线",
35+
"grid": "Grid 删格",
36+
"layout": "Layout 布局",
37+
"Split": "Split 面板分割",
38+
"form": "Form 表单",
39+
"radio": "Radio 单选框",
40+
"checkbox": "Checkbox 多选框",
41+
"cascader": "Cascader 级联选择",
42+
"input": "Input 输入框",
43+
"file-input": "FileInput 上传输入框",
44+
"pin-code": "PinCode PIN码",
45+
"rate": "Rate 评分",
46+
"switch": "Switch 开关",
47+
"select": "Select 选择器",
48+
"search-select": "SearchSelect 搜索选择器",
49+
"search-tree": "SearchTree 搜索树形控件",
50+
"slider": "Slider 滑块输入条",
51+
"tree-checked": "TreeChecked 树形选择控件",
52+
"transfer": "Transfer 穿梭框",
53+
"textarea": "Textarea 多行文本输入框",
54+
"react-color": "Color 颜色选择器",
55+
"calendar": "Calendar 日历",
56+
"date-picker": "DatePicker 日期选择器",
57+
"date-input": "DateInput 日期输入框",
58+
"time-picker": "TimePicker 时间输入框",
59+
"month-picker": "MonthPicker 月份选择器",
60+
"formatter": "formatter 时间格式化",
61+
"avatar": "Avatar 头像",
62+
"badge": "Badge 标记",
63+
"card": "Card 卡片",
64+
"carousel": "Carousel 走马灯",
65+
"collapse": "Collapse 折叠面板",
66+
"descriptions": "Descriptions 描述列表",
67+
"tag": "Tag 标签",
68+
"tree": "Tree 树形控件",
69+
"table": "Table 表格",
70+
"progress": "Progress 进度条",
71+
"list": "List 列表",
72+
"auto-link": "AutoLink 文本超链接",
73+
"empty": "Empty 空状态",
74+
"react-heat-map": "HeatMap 日历热图",
75+
"react-markdown-preview": "Markdown Preview",
76+
"affix": "Affix 图钉",
77+
"breadcrumb": "Breadcrumb 面包屑",
78+
"dropdown": "Dropdown 下拉菜单",
79+
"menu": "Menu 菜单",
80+
"pagination": "Pagination 分页",
81+
"steps": "Steps 步骤条",
82+
"tabs": "Tabs 标签页",
83+
"overlay": "Overlay 基础弹出层",
84+
"overlay-trigger": "OverlayTrigger 基础弹出触发",
85+
"alert": "Alert 确认对话框",
86+
"drawer": "Drawer 抽屉",
87+
"modal": "Modal 模态对话框",
88+
"message": "Message 警告提示",
89+
"loader": "Loader 加载器",
90+
"notify": "Notify 消息通知",
91+
"popover": "Popover 气泡卡片",
92+
"tooltip": "Tooltip 文字提示",
93+
"react-amap": "AMap 高德地图",
94+
"react-baidu-map": "BaiduMap 百度地图",
95+
"react-textarea-code-editor": "Textarea CodeEditor",
96+
"react-md-editor": "MDEditor 编辑器",
97+
"react-markdown-editor": "Markdown Editor 编辑器",
98+
"react-code-preview": "CodePreview JS编辑预览",
99+
"react-codemirror": "Codemirror 代码编辑器",
100+
"react-monacoeditor": "MonacoEditor 代码编辑器",
101+
"back-top": "BackTop 返回顶部",
102+
"copy-to-clipboard": "CopyToClipboard 复制",
103+
"portal": "Portal 入口",
104+
"react-github-corners": "Github Corners",
105+
"react-only-when": "Only When",
106+
"react-run-web": "Run Web"
107+
},
108+
"/extensions": "扩展",
109+
"issue": "提交问题",
110+
"github": "Github",
111+
"gitee": "Gitee"
112+
},
113+
"footer": {
114+
"greeting": "犯了错误还是想对文件做出贡献?",
115+
"greetLinkText": "在Github上编辑本页!",
116+
"issues": "反馈建议",
117+
"bug": "提交bug",
118+
"github": "Github",
119+
"kkt": "kkt",
120+
"kkt_ssr": "@kkt/ssr",
121+
"io": "国内镜像"
122+
}
123+
}

website/src/components/Nav/index.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import logo from '../icons/logo';
88
import menu from '../icons/menu';
99
import pkg from 'uiw/package.json';
1010
import { useTranslation } from 'react-i18next';
11-
import { LayoutMenuType } from 'locale/menu/layoutMenuType';
11+
import data from '../../menu.json';
1212

1313
export default function Nav() {
1414
const { state, dispatch } = useContext(ThemeContext);
1515
const { t: trans, i18n } = useTranslation();
1616
// eslint-disable-next-line react-hooks/exhaustive-deps
17-
const data = useMemo(() => JSON.parse(trans('menu')), [i18n.language]);
17+
// const data = useMemo(() => JSON.parse(trans('menu')), [i18n.language]);
1818

1919
const changeLanguage = (e: ChangeEvent<HTMLSelectElement>) => {
2020
i18n.changeLanguage(e.target.value);
@@ -33,15 +33,20 @@ export default function Nav() {
3333
</Link>
3434
</div>
3535
<div className={[styles.nav, state.layout === 'left' ? null : styles.navTop].filter(Boolean).join(' ').trim()}>
36-
{data.map(({ path, name, icon }: LayoutMenuType, idx: number) => {
36+
{data.map(({ path, name, icon, translation }, idx: number) => {
3737
if (Object.keys(nav).includes(icon)) {
3838
icon = (nav as any)[icon];
3939
}
40+
let newName = translation ? trans(`menu.${translation}`) : trans(`menu.${path}`);
41+
if (/^\//.test(path)) {
42+
newName = trans(`menu.${path}`);
43+
}
44+
4045
if (/^https?:(?:\/\/)?/.test(path)) {
4146
if (state.layout === 'top') {
4247
return (
4348
<a key={idx} target="__blank" href={path} className={styles.outerUrl}>
44-
{icon} <span>{name}</span>
49+
{icon} <span>{newName}</span>
4550
</a>
4651
);
4752
}
@@ -50,7 +55,7 @@ export default function Nav() {
5055
usePortal={false}
5156
key={idx}
5257
placement={state.layout === 'left' ? 'right' : 'bottom'}
53-
content={<span style={{ whiteSpace: 'nowrap' }}>{name}</span>}
58+
content={<span style={{ whiteSpace: 'nowrap' }}>{newName}</span>}
5459
>
5560
<a target="__blank" href={path} className={styles.outerUrl}>
5661
{icon}
@@ -69,7 +74,7 @@ export default function Nav() {
6974
// @ts-ignore
7075
style={({ isActive }) => (isActive ? activeStyle : undefined)}
7176
>
72-
{icon} <span>{name}</span>
77+
{icon} <span>{newName}</span>
7378
</NavLink>
7479
);
7580
}
@@ -79,7 +84,7 @@ export default function Nav() {
7984
usePortal={false}
8085
key={idx}
8186
placement={state.layout === 'left' ? 'right' : 'bottom'}
82-
content={<span style={{ whiteSpace: 'nowrap' }}>{name}</span>}
87+
content={<span style={{ whiteSpace: 'nowrap' }}>{newName}</span>}
8388
>
8489
<NavLink
8590
to={path}
@@ -95,7 +100,7 @@ export default function Nav() {
95100

96101
<div className={[styles.btn, state.layout === 'left' ? null : styles.btnTop].filter(Boolean).join(' ').trim()}>
97102
<select value={i18n.language} onChange={(e) => changeLanguage(e)}>
98-
<option value="zh-CN"></option>
103+
<option value="zh-CN">简体中文</option>
99104
<option value="en-US">English</option>
100105
</select>
101106

0 commit comments

Comments
 (0)