Skip to content

Commit

Permalink
fix: Add Chinese (zh) locale
Browse files Browse the repository at this point in the history
  • Loading branch information
iamkun committed Mar 10, 2020
1 parent 9dd69ed commit f9b8945
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
26 changes: 11 additions & 15 deletions src/locale/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ const locale = {
weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
weekdaysShort: '周日_周一_周二_周三_周四_周五_周六'.split('_'),
weekdaysMin: '日_一_二_三_四_五_六'.split('_'),
// prettier conflicts with eslint, so
// prettier-ignore
months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
ordinal: (number, period) => {
switch (period) {
case 'W':
return `${number}周`
return `${number}周`
default:
return `${number}日`
}
Expand All @@ -36,20 +34,18 @@ const locale = {
future: '%s后',
past: '%s前',
s: '几秒',
m: '1分钟',
mm: '%d分钟',
h: '1小时',
hh: '%d小时',
d: '1天',
dd: '%d天',
M: '1个月',
MM: '%d个月',
y: '1年',
yy: '%d年'
m: '1 分钟',
mm: '%d 分钟',
h: '1 小时',
hh: '%d 小时',
d: '1 天',
dd: '%d 天',
M: '1 个月',
MM: '%d 个月',
y: '1 年',
yy: '%d 年'
},
meridiem: (hour, minute) => {
// prettier conflicts with eslint, so
// prettier-ignore
const hm = (hour * 100) + minute
if (hm < 600) {
return '凌晨'
Expand Down
2 changes: 1 addition & 1 deletion test/locale/zh.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const zh = dayjs().locale('zh')
const zhCN = dayjs().locale('zh-cn')

test('ordinal', () => {
expect(zh.format('wo')).toEqual(`${zh.format('w')}周`)
expect(zh.format('wo')).toEqual(`${zh.format('w')}周`)
})

test('Meridiem', () => {
Expand Down

0 comments on commit f9b8945

Please sign in to comment.