From f9b89453166d8b53d33b1d7eefd9942022552e6e Mon Sep 17 00:00:00 2001 From: iamkun Date: Tue, 10 Mar 2020 11:48:57 +0800 Subject: [PATCH] fix: Add Chinese (zh) locale --- src/locale/zh.js | 26 +++++++++++--------------- test/locale/zh.test.js | 2 +- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/locale/zh.js b/src/locale/zh.js index b412dc8c2..c369ddcf1 100644 --- a/src/locale/zh.js +++ b/src/locale/zh.js @@ -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}日` } @@ -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 '凌晨' diff --git a/test/locale/zh.test.js b/test/locale/zh.test.js index 2748a510a..f018eda19 100644 --- a/test/locale/zh.test.js +++ b/test/locale/zh.test.js @@ -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', () => {