-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[new locale] (zh-mo) Add Chinese Macau #5356
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
//! moment.js locale configuration | ||
//! locale : Chinese (Taiwan) [zh-tw] | ||
//! author : Ben : https://github.com/ben-lin | ||
//! author : Chris Lam : https://github.com/hehachris | ||
//! author : Tan Yuanhong : https://github.com/le0tan | ||
|
||
import moment from '../moment'; | ||
|
||
export default moment.defineLocale('zh-mo', { | ||
months : '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'), | ||
monthsShort : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'), | ||
weekdays : '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'), | ||
weekdaysShort : '週日_週一_週二_週三_週四_週五_週六'.split('_'), | ||
weekdaysMin : '日_一_二_三_四_五_六'.split('_'), | ||
longDateFormat : { | ||
LT : 'HH:mm', | ||
LTS : 'HH:mm:ss', | ||
L : 'DD/MM/YYYY', | ||
LL : 'YYYY年M月D日', | ||
LLL : 'YYYY年M月D日 HH:mm', | ||
LLLL : 'YYYY年M月D日dddd HH:mm', | ||
l : 'D/M/YYYY', | ||
ll : 'YYYY年M月D日', | ||
lll : 'YYYY年M月D日 HH:mm', | ||
llll : 'YYYY年M月D日dddd HH:mm' | ||
}, | ||
meridiemParse: /凌晨|早上|上午|中午|下午|晚上/, | ||
meridiemHour : function (hour, meridiem) { | ||
if (hour === 12) { | ||
hour = 0; | ||
} | ||
if (meridiem === '凌晨' || meridiem === '早上' || meridiem === '上午') { | ||
return hour; | ||
} else if (meridiem === '中午') { | ||
return hour >= 11 ? hour : hour + 12; | ||
} else if (meridiem === '下午' || meridiem === '晚上') { | ||
return hour + 12; | ||
} | ||
}, | ||
meridiem : function (hour, minute, isLower) { | ||
var hm = hour * 100 + minute; | ||
if (hm < 600) { | ||
return '凌晨'; | ||
} else if (hm < 900) { | ||
return '早上'; | ||
} else if (hm < 1130) { | ||
return '上午'; | ||
} else if (hm < 1230) { | ||
return '中午'; | ||
} else if (hm < 1800) { | ||
return '下午'; | ||
} else { | ||
return '晚上'; | ||
} | ||
}, | ||
calendar : { | ||
sameDay : '[今天] LT', | ||
nextDay : '[明天] LT', | ||
nextWeek : '[下]dddd LT', | ||
lastDay : '[昨天] LT', | ||
lastWeek : '[上]dddd LT', | ||
sameElse : 'L' | ||
}, | ||
dayOfMonthOrdinalParse: /\d{1,2}(日|月|週)/, | ||
ordinal : function (number, period) { | ||
switch (period) { | ||
case 'd' : | ||
case 'D' : | ||
case 'DDD' : | ||
return number + '日'; | ||
case 'M' : | ||
return number + '月'; | ||
case 'w' : | ||
case 'W' : | ||
return number + '週'; | ||
default : | ||
return number; | ||
} | ||
}, | ||
relativeTime : { | ||
future : '%s內', | ||
past : '%s前', | ||
s : '幾秒', | ||
ss : '%d 秒', | ||
m : '1 分鐘', | ||
mm : '%d 分鐘', | ||
h : '1 小時', | ||
hh : '%d 小時', | ||
d : '1 天', | ||
dd : '%d 天', | ||
M : '1 個月', | ||
MM : '%d 個月', | ||
y : '1 年', | ||
yy : '%d 年' | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
import {test} from '../qunit'; | ||
import {localeModule} from '../qunit-locale'; | ||
import moment from '../../moment'; | ||
localeModule('zh-mo'); | ||
|
||
test('parse', function (assert) { | ||
var tests = '一月 1月_二月 2月_三月 3月_四月 4月_五月 5月_六月 6月_七月 7月_八月 8月_九月 9月_十月 10月_十一月 11月_十二月 12月'.split('_'), i; | ||
function equalTest(input, mmm, i) { | ||
assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1)); | ||
} | ||
for (i = 0; i < 12; i++) { | ||
tests[i] = tests[i].split(' '); | ||
equalTest(tests[i][0], 'MMM', i); | ||
equalTest(tests[i][1], 'MMM', i); | ||
equalTest(tests[i][0], 'MMMM', i); | ||
equalTest(tests[i][1], 'MMMM', i); | ||
equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i); | ||
equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i); | ||
equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i); | ||
equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i); | ||
} | ||
}); | ||
|
||
test('format', function (assert) { | ||
var a = [ | ||
['dddd, MMMM Do YYYY, a h:mm:ss', '星期日, 二月 14日 2010, 下午 3:25:50'], | ||
['ddd, Ah', '週日, 下午3'], | ||
['M Mo MM MMMM MMM', '2 2月 02 二月 2月'], | ||
['YYYY YY', '2010 10'], | ||
['D Do DD', '14 14日 14'], | ||
['d do dddd ddd dd', '0 0日 星期日 週日 日'], | ||
['DDD DDDo DDDD', '45 45日 045'], | ||
['w wo ww', '8 8週 08'], | ||
['h hh', '3 03'], | ||
['H HH', '15 15'], | ||
['m mm', '25 25'], | ||
['s ss', '50 50'], | ||
['a A', '下午 下午'], | ||
['[這年的第] DDDo', '這年的第 45日'], | ||
['LTS', '15:25:50'], | ||
['L', '14/02/2010'], | ||
['LL', '2010年2月14日'], | ||
['LLL', '2010年2月14日 15:25'], | ||
['LLLL', '2010年2月14日星期日 15:25'], | ||
['l', '14/2/2010'], | ||
['ll', '2010年2月14日'], | ||
['lll', '2010年2月14日 15:25'], | ||
['llll', '2010年2月14日星期日 15:25'] | ||
], | ||
b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)), | ||
i; | ||
|
||
for (i = 0; i < a.length; i++) { | ||
assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]); | ||
} | ||
}); | ||
|
||
test('format month', function (assert) { | ||
var expected = '一月 1月_二月 2月_三月 3月_四月 4月_五月 5月_六月 6月_七月 7月_八月 8月_九月 9月_十月 10月_十一月 11月_十二月 12月'.split('_'), i; | ||
|
||
for (i = 0; i < expected.length; i++) { | ||
assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]); | ||
} | ||
}); | ||
|
||
test('format week', function (assert) { | ||
var expected = '星期日 週日 日_星期一 週一 一_星期二 週二 二_星期三 週三 三_星期四 週四 四_星期五 週五 五_星期六 週六 六'.split('_'), i; | ||
|
||
for (i = 0; i < expected.length; i++) { | ||
assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]); | ||
} | ||
}); | ||
|
||
test('from', function (assert) { | ||
var start = moment([2007, 1, 28]); | ||
assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), '幾秒', '44 seconds = a few seconds'); | ||
assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), '1 分鐘', '45 seconds = a minute'); | ||
assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), '1 分鐘', '89 seconds = a minute'); | ||
assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 分鐘', '90 seconds = 2 minutes'); | ||
assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 分鐘', '44 minutes = 44 minutes'); | ||
assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), '1 小時', '45 minutes = an hour'); | ||
assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), '1 小時', '89 minutes = an hour'); | ||
assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 小時', '90 minutes = 2 hours'); | ||
assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 小時', '5 hours = 5 hours'); | ||
assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 小時', '21 hours = 21 hours'); | ||
assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), '1 天', '22 hours = a day'); | ||
assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), '1 天', '35 hours = a day'); | ||
assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 天', '36 hours = 2 days'); | ||
assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), '1 天', '1 day = a day'); | ||
assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 天', '5 days = 5 days'); | ||
assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 天', '25 days = 25 days'); | ||
assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), '1 個月', '26 days = a month'); | ||
assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), '1 個月', '30 days = a month'); | ||
assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), '1 個月', '43 days = a month'); | ||
assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 個月', '46 days = 2 months'); | ||
assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 個月', '75 days = 2 months'); | ||
assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 個月', '76 days = 3 months'); | ||
assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), '1 個月', '1 month = a month'); | ||
assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 個月', '5 months = 5 months'); | ||
assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), '1 年', '345 days = a year'); | ||
assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 年', '548 days = 2 years'); | ||
assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), '1 年', '1 year = a year'); | ||
assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 年', '5 years = 5 years'); | ||
}); | ||
|
||
test('suffix', function (assert) { | ||
assert.equal(moment(30000).from(0), '幾秒內', 'prefix'); | ||
assert.equal(moment(0).from(30000), '幾秒前', 'suffix'); | ||
}); | ||
|
||
test('now from now', function (assert) { | ||
assert.equal(moment().fromNow(), '幾秒前', 'now from now should display as in the past'); | ||
}); | ||
|
||
test('fromNow', function (assert) { | ||
assert.equal(moment().add({s: 30}).fromNow(), '幾秒內', 'in a few seconds'); | ||
assert.equal(moment().add({d: 5}).fromNow(), '5 天內', 'in 5 days'); | ||
}); | ||
|
||
test('calendar day', function (assert) { | ||
var a = moment().hours(12).minutes(0).seconds(0); | ||
|
||
assert.equal(moment(a).calendar(), '今天 12:00', 'today at the same time'); | ||
assert.equal(moment(a).add({m: 25}).calendar(), '今天 12:25', 'Now plus 25 min'); | ||
assert.equal(moment(a).add({h: 1}).calendar(), '今天 13:00', 'Now plus 1 hour'); | ||
assert.equal(moment(a).add({d: 1}).calendar(), '明天 12:00', 'tomorrow at the same time'); | ||
assert.equal(moment(a).subtract({h: 1}).calendar(), '今天 11:00', 'Now minus 1 hour'); | ||
assert.equal(moment(a).subtract({d: 1}).calendar(), '昨天 12:00', 'yesterday at the same time'); | ||
}); | ||
|
||
test('calendar next week', function (assert) { | ||
var i, m; | ||
for (i = 2; i < 7; i++) { | ||
m = moment().add({d: i}); | ||
assert.equal(m.calendar(), m.format('[下]dddd LT'), 'Today + ' + i + ' days current time'); | ||
m.hours(0).minutes(0).seconds(0).milliseconds(0); | ||
assert.equal(m.calendar(), m.format('[下]dddd LT'), 'Today + ' + i + ' days beginning of day'); | ||
m.hours(23).minutes(59).seconds(59).milliseconds(999); | ||
assert.equal(m.calendar(), m.format('[下]dddd LT'), 'Today + ' + i + ' days end of day'); | ||
} | ||
}); | ||
|
||
test('calendar last week', function (assert) { | ||
var i, m; | ||
for (i = 2; i < 7; i++) { | ||
m = moment().subtract({d: i}); | ||
assert.equal(m.calendar(), m.format('[上]dddd LT'), 'Today - ' + i + ' days current time'); | ||
m.hours(0).minutes(0).seconds(0).milliseconds(0); | ||
assert.equal(m.calendar(), m.format('[上]dddd LT'), 'Today - ' + i + ' days beginning of day'); | ||
m.hours(23).minutes(59).seconds(59).milliseconds(999); | ||
assert.equal(m.calendar(), m.format('[上]dddd LT'), 'Today - ' + i + ' days end of day'); | ||
} | ||
}); | ||
|
||
test('calendar all else', function (assert) { | ||
var weeksAgo = moment().subtract({w: 1}), | ||
weeksFromNow = moment().add({w: 1}); | ||
|
||
assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago'); | ||
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week'); | ||
|
||
weeksAgo = moment().subtract({w: 2}); | ||
weeksFromNow = moment().add({w: 2}); | ||
|
||
assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago'); | ||
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks'); | ||
}); | ||
|
||
test('meridiem', function (assert) { | ||
assert.equal(moment([2011, 2, 23, 0, 0]).format('a'), '凌晨', 'before dawn'); | ||
assert.equal(moment([2011, 2, 23, 6, 0]).format('a'), '早上', 'morning'); | ||
assert.equal(moment([2011, 2, 23, 9, 0]).format('a'), '上午', 'before noon'); | ||
assert.equal(moment([2011, 2, 23, 12, 0]).format('a'), '中午', 'noon'); | ||
assert.equal(moment([2011, 2, 23, 13, 0]).format('a'), '下午', 'after noon'); | ||
assert.equal(moment([2011, 2, 23, 18, 0]).format('a'), '晚上', 'night'); | ||
|
||
assert.equal(moment([2011, 2, 23, 0, 0]).format('A'), '凌晨', 'before dawn'); | ||
assert.equal(moment([2011, 2, 23, 6, 0]).format('A'), '早上', 'morning'); | ||
assert.equal(moment([2011, 2, 23, 9, 0]).format('A'), '上午', 'before noon'); | ||
assert.equal(moment([2011, 2, 23, 12, 0]).format('A'), '中午', 'noon'); | ||
assert.equal(moment([2011, 2, 23, 13, 0]).format('A'), '下午', 'afternoon'); | ||
assert.equal(moment([2011, 2, 23, 18, 0]).format('A'), '晚上', 'night'); | ||
}); | ||
|
||
test('weeks year starting sunday format', function (assert) { | ||
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1週', 'Jan 1 2012 應該是第 1週'); | ||
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1週', 'Jan 7 2012 應該是第 1週'); | ||
assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2週', 'Jan 8 2012 應該是第 2週'); | ||
assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2週', 'Jan 14 2012 應該是第 2週'); | ||
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3週', 'Jan 15 2012 應該是第 3週'); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You missed this.