Skip to content

Commit 34bb158

Browse files
committed
fix: revise inspection comments
1 parent 44e4f4d commit 34bb158

File tree

3 files changed

+45
-45
lines changed

3 files changed

+45
-45
lines changed

examples/sites/src/i18n/index.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@ import esLA from './es.json'
77
import ptBR from './pt.json'
88

99
const messages = { enUS: { ...en }, zhCN: { ...zh }, esLA: { ...esLA }, ptBR: { ...ptBR } }
10-
$local._lang =
11-
$local._lang === 'zhCN'
12-
? 'zhCN'
13-
: $local._lang === 'enUS'
14-
? 'enUS'
15-
: $local._lang === 'esLA'
16-
? 'esLA'
17-
: $local._lang === 'ptBR'
18-
? 'ptBR'
19-
: 'zhCN'
10+
11+
const langMap = new Map([
12+
['zhCN', 'zhCN'],
13+
['enUS', 'enUS'],
14+
['esLA', 'esLA'],
15+
['ptBR', 'ptBR']
16+
])
17+
18+
$local._lang = langMap.get($local._lang) || 'zhCN'
2019

2120
const customCreateI18n = ({ locale, messages }) =>
2221
createI18n({
@@ -33,16 +32,17 @@ const i18n = initI18n({
3332
messages
3433
})
3534
const i18nByKey = i18n.global.t
36-
const getWord = (cn, en, es, pt) =>
37-
i18n.global.locale === 'zhCN'
38-
? cn
39-
: i18n.global.locale === 'enUS'
40-
? en
41-
: i18n.global.locale === 'esLA'
42-
? en
43-
: i18n.global.locale === 'ptBR'
44-
? en
45-
: cn
35+
const getWord = (cn, en, es, pt) => {
36+
const localeMap = new Map([
37+
['zhCN', cn], // 简体中文
38+
['enUS', en], // 英语
39+
['esLA', es], // 西班牙语
40+
['ptBR', pt] // 葡萄牙语
41+
])
42+
const currentLocale = i18n.global.locale
43+
44+
return localeMap.get(currentLocale) ?? cn
45+
}
4646

4747
export { i18n, i18nByKey, getWord }
4848

examples/sites/src/tools/useStyleSettings.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,30 @@
22
const getStyleSettings = (i18nByKey) => {
33
const styleSettings = [
44
/** 官网英文适配后放开 */
5-
{
6-
// 语言选择
7-
name: 'localeMode',
8-
defaultValue: 'zhCN',
9-
title: i18nByKey('localeType'),
10-
options: [
11-
{
12-
value: 'zhCN',
13-
text: i18nByKey('zh-cn')
14-
},
15-
{
16-
value: 'enUS',
17-
text: i18nByKey('en-us')
18-
},
19-
{
20-
value: 'esLA',
21-
text: i18nByKey('es-la')
22-
},
23-
{
24-
value: 'ptBR',
25-
text: i18nByKey('pt-br')
26-
}
27-
]
28-
},
5+
// {
6+
// // 语言选择
7+
// name: 'localeMode',
8+
// defaultValue: 'zhCN',
9+
// title: i18nByKey('localeType'),
10+
// options: [
11+
// {
12+
// value: 'zhCN',
13+
// text: i18nByKey('zh-cn')
14+
// },
15+
// {
16+
// value: 'enUS',
17+
// text: i18nByKey('en-us')
18+
// },
19+
// {
20+
// value: 'esLA',
21+
// text: i18nByKey('es-la')
22+
// },
23+
// {
24+
// value: 'ptBR',
25+
// text: i18nByKey('pt-br')
26+
// }
27+
// ]
28+
// },
2929
{
3030
// 示例代码风格
3131
name: 'apiMode',

packages/vue/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,4 +237,4 @@
237237
"vue2.7": "npm:vue@2.7.10",
238238
"vue3": "npm:vue@3.3.9"
239239
}
240-
}
240+
}

0 commit comments

Comments
 (0)