Skip to content

Commit

Permalink
chore: opt zh-CN locale to reduce bundle size (ant-design#6592)
Browse files Browse the repository at this point in the history
* chore: reduce bundle size of zh-CN only apps

* test(locale): zh-CN keys and base
  • Loading branch information
guoyunhe authored Apr 9, 2024
1 parent e55ddf9 commit d4ff76b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
18 changes: 18 additions & 0 deletions src/locales/zh-CN.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { base } from './base'
import zhCN from './zh-CN'

test('zh-CN', () => {
function compareKeys(a: any, b: any): boolean {
return !Object.keys(a).some(key => {
if (typeof b[key] === 'string') {
return false
} else if (b[key]) {
return !compareKeys(a[key], b[key])
} else {
return true
}
})
}

expect(compareKeys(base, zhCN)).toBeTruthy()
})
7 changes: 3 additions & 4 deletions src/locales/zh-CN.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { mergeLocale } from '../utils/merge-locale'
import { base } from './base'
import { Locale } from './base'

const typeTemplate = '${label}不是一个有效的${type}'

const zhCN = mergeLocale(base, {
const zhCN: Locale = {
locale: 'zh-CH',
common: {
confirm: '确定',
Expand Down Expand Up @@ -140,6 +139,6 @@ const zhCN = mergeLocale(base, {
Selector: {
name: '选择组',
},
})
}

export default zhCN

0 comments on commit d4ff76b

Please sign in to comment.