From a119b8dfc194bb96bfe3b2bccc0ded4a53d763d6 Mon Sep 17 00:00:00 2001 From: Tim Wood Date: Mon, 14 Jan 2013 11:21:57 -0800 Subject: [PATCH] adding changes for #484 to support ordinals without numbers --- lang/ar-ma.js | 3 --- lang/ar.js | 3 --- lang/bg.js | 14 +++++++------- lang/ca.js | 4 +--- lang/cs.js | 4 +--- lang/cv.js | 4 +--- lang/da.js | 4 +--- lang/de.js | 4 +--- lang/en-ca.js | 5 +++-- lang/en-gb.js | 5 +++-- lang/eo.js | 4 +--- lang/es.js | 4 +--- lang/et.js | 4 +--- lang/eu.js | 4 +--- lang/fi.js | 4 +--- lang/fr-ca.js | 2 +- lang/fr.js | 2 +- lang/gl.js | 4 +--- lang/he.js | 3 --- lang/hu.js | 5 +---- lang/id.js | 3 --- lang/is.js | 4 +--- lang/it.js | 4 +--- lang/ja.js | 3 --- lang/jp.js | 3 --- lang/ko.js | 4 +--- lang/kr.js | 4 +--- lang/lv.js | 4 +--- lang/nb.js | 4 +--- lang/ne.js | 3 --- lang/nl.js | 2 +- lang/pl.js | 4 +--- lang/pt-br.js | 4 +--- lang/pt.js | 4 +--- lang/ro.js | 3 --- lang/ru.js | 4 +--- lang/sl.js | 4 +--- lang/sv.js | 5 +++-- lang/th.js | 3 --- lang/tr.js | 4 ++-- lang/tzm-la.js | 3 --- lang/tzm.js | 3 --- lang/zh-cn.js | 3 --- lang/zh-tw.js | 3 --- moment.js | 11 ++++++----- 45 files changed, 50 insertions(+), 132 deletions(-) diff --git a/lang/ar-ma.js b/lang/ar-ma.js index 71868a9b6..bdb472c21 100644 --- a/lang/ar-ma.js +++ b/lang/ar-ma.js @@ -39,9 +39,6 @@ require('../moment').lang('ar-ma', { y : "سنة", yy : "%d سنوات" }, - ordinal : function (number) { - return ''; - }, week : { dow : 6, // Saturday is the first day of the week. doy : 12 // The week that contains Jan 1st is the first week of the year. diff --git a/lang/ar.js b/lang/ar.js index 0b916fe94..cfa420acd 100644 --- a/lang/ar.js +++ b/lang/ar.js @@ -38,9 +38,6 @@ require('../moment').lang('ar', { y : "سنة", yy : "%d سنوات" }, - ordinal : function (number) { - return ''; - }, week : { dow : 6, // Saturday is the first day of the week. doy : 12 // The week that contains Jan 1st is the first week of the year. diff --git a/lang/bg.js b/lang/bg.js index d94de6e50..c5b47851e 100644 --- a/lang/bg.js +++ b/lang/bg.js @@ -54,19 +54,19 @@ require('../moment').lang('bg', { var lastDigit = number % 10, last2Digits = number % 100; if (number === 0) { - return '-ев'; + return number + '-ев'; } else if (last2Digits === 0) { - return '-ен'; + return number + '-ен'; } else if (last2Digits > 10 && last2Digits < 20) { - return '-ти'; + return number + '-ти'; } else if (lastDigit === 1) { - return '-ви'; + return number + '-ви'; } else if (lastDigit === 2) { - return '-ри'; + return number + '-ри'; } else if (lastDigit === 7 || lastDigit === 8) { - return '-ми'; + return number + '-ми'; } else { - return '-ти'; + return number + '-ти'; } }, week : { diff --git a/lang/ca.js b/lang/ca.js index e95496d52..9bbe96357 100644 --- a/lang/ca.js +++ b/lang/ca.js @@ -48,9 +48,7 @@ require('../moment').lang('ca', { y : "un any", yy : "%d anys" }, - ordinal : function (number) { - return 'º'; - }, + ordinal : '%dº', week : { dow : 1, // Monday is the first day of the week. doy : 4 // The week that contains Jan 4th is the first week of the year. diff --git a/lang/cs.js b/lang/cs.js index fb3d87a4c..cb98b2eb3 100644 --- a/lang/cs.js +++ b/lang/cs.js @@ -137,9 +137,7 @@ require('../moment').lang('cs', { y : translate, yy : translate }, - ordinal : function (number) { - return '.'; - }, + ordinal : '%d.', week : { dow : 1, // Monday is the first day of the week. doy : 4 // The week that contains Jan 4th is the first week of the year. diff --git a/lang/cv.js b/lang/cv.js index 7ca3f6ab5..802aa2b4d 100644 --- a/lang/cv.js +++ b/lang/cv.js @@ -42,9 +42,7 @@ require('../moment').lang('cv', { y : "пĕр çул", yy : "%d çул" }, - ordinal : function (number) { - return '-мĕш'; - }, + ordinal : '%d-мĕш', week : { dow : 1, // Monday is the first day of the week. doy : 7 // The week that contains Jan 1st is the first week of the year. diff --git a/lang/da.js b/lang/da.js index 4f031672c..4f4141f90 100644 --- a/lang/da.js +++ b/lang/da.js @@ -38,9 +38,7 @@ require('../moment').lang('da', { y : "år", yy : "%d år" }, - ordinal : function (number) { - return '.'; - }, + ordinal : '%d.', week : { dow : 1, // Monday is the first day of the week. doy : 4 // The week that contains Jan 4th is the first week of the year. diff --git a/lang/de.js b/lang/de.js index 1061f1996..c3a2e47d3 100644 --- a/lang/de.js +++ b/lang/de.js @@ -38,9 +38,7 @@ require('../moment').lang('de', { y : "einem Jahr", yy : "%d Jahren" }, - ordinal : function (number) { - return '.'; - }, + ordinal : '%d.', week : { dow : 1, // Monday is the first day of the week. doy : 4 // The week that contains Jan 4th is the first week of the year. diff --git a/lang/en-ca.js b/lang/en-ca.js index c3cf5aa0d..b432298ad 100644 --- a/lang/en-ca.js +++ b/lang/en-ca.js @@ -39,10 +39,11 @@ require('../moment').lang('en-ca', { yy : "%d years" }, ordinal : function (number) { - var b = number % 10; - return (~~ (number % 100 / 10) === 1) ? 'th' : + var b = number % 10, + output = (~~ (number % 100 / 10) === 1) ? 'th' : (b === 1) ? 'st' : (b === 2) ? 'nd' : (b === 3) ? 'rd' : 'th'; + return number + output; } }); diff --git a/lang/en-gb.js b/lang/en-gb.js index efa722454..98bc95be5 100644 --- a/lang/en-gb.js +++ b/lang/en-gb.js @@ -39,11 +39,12 @@ require('../moment').lang('en-gb', { yy : "%d years" }, ordinal : function (number) { - var b = number % 10; - return (~~ (number % 100 / 10) === 1) ? 'th' : + var b = number % 10, + output = (~~ (number % 100 / 10) === 1) ? 'th' : (b === 1) ? 'st' : (b === 2) ? 'nd' : (b === 3) ? 'rd' : 'th'; + return number + output; }, week : { dow : 1, // Monday is the first day of the week. diff --git a/lang/eo.js b/lang/eo.js index 72b91d8c0..6637fa29c 100644 --- a/lang/eo.js +++ b/lang/eo.js @@ -47,9 +47,7 @@ require('../moment').lang('eo', { y : "jaro", yy : "%d jaroj" }, - ordinal : function (number) { - return "a"; - }, + ordinal : "%da", week : { dow : 1, // Monday is the first day of the week. doy : 7 // The week that contains Jan 1st is the first week of the year. diff --git a/lang/es.js b/lang/es.js index eb085fc6c..f935bd188 100644 --- a/lang/es.js +++ b/lang/es.js @@ -48,9 +48,7 @@ require('../moment').lang('es', { y : "un año", yy : "%d años" }, - ordinal : function (number) { - return 'º'; - }, + ordinal : '%dº', week : { dow : 1, // Monday is the first day of the week. doy : 4 // The week that contains Jan 4th is the first week of the year. diff --git a/lang/et.js b/lang/et.js index 4168fe3d3..5e07802bd 100644 --- a/lang/et.js +++ b/lang/et.js @@ -42,9 +42,7 @@ require('../moment').lang('et', { y : "aasta", yy : "%d aastat" }, - ordinal : function (number) { - return '.'; - }, + ordinal : '%d.', week : { dow : 1, // Monday is the first day of the week. doy : 4 // The week that contains Jan 4th is the first week of the year. diff --git a/lang/eu.js b/lang/eu.js index 2411ccf9b..414a34173 100644 --- a/lang/eu.js +++ b/lang/eu.js @@ -38,9 +38,7 @@ require('../moment').lang('eu', { y : "urte bat", yy : "%d urte" }, - ordinal : function (number) { - return '.'; - }, + ordinal : '%d.', week : { dow : 1, // Monday is the first day of the week. doy : 7 // The week that contains Jan 1st is the first week of the year. diff --git a/lang/fi.js b/lang/fi.js index 7b495273a..ee61c8915 100644 --- a/lang/fi.js +++ b/lang/fi.js @@ -81,9 +81,7 @@ require('../moment').lang('fi', { y : translate, yy : translate }, - ordinal : function (number) { - return "."; - }, + ordinal : "%d.", week : { dow : 1, // Monday is the first day of the week. doy : 4 // The week that contains Jan 4th is the first week of the year. diff --git a/lang/fr-ca.js b/lang/fr-ca.js index f97da7ac8..7a7afa63b 100644 --- a/lang/fr-ca.js +++ b/lang/fr-ca.js @@ -39,6 +39,6 @@ require('../moment').lang('fr-ca', { yy : "%d années" }, ordinal : function (number) { - return number === 1 ? 'er' : 'ème'; + return number + (number === 1 ? 'er' : 'ème'); } }); diff --git a/lang/fr.js b/lang/fr.js index c87b8db00..19264f141 100644 --- a/lang/fr.js +++ b/lang/fr.js @@ -39,7 +39,7 @@ require('../moment').lang('fr', { yy : "%d années" }, ordinal : function (number) { - return number === 1 ? 'er' : 'ème'; + return number + (number === 1 ? 'er' : 'ème'); }, week : { dow : 1, // Monday is the first day of the week. diff --git a/lang/gl.js b/lang/gl.js index ef8fc7b58..10044ffa1 100644 --- a/lang/gl.js +++ b/lang/gl.js @@ -48,9 +48,7 @@ require('../moment').lang('gl', { y : "un ano", yy : "%d anos" }, - ordinal : function (number) { - return 'º'; - }, + ordinal : '%dº', week : { dow : 1, // Monday is the first day of the week. doy : 7 // The week that contains Jan 1st is the first week of the year. diff --git a/lang/he.js b/lang/he.js index ac781d347..e96559729 100644 --- a/lang/he.js +++ b/lang/he.js @@ -38,8 +38,5 @@ require('../moment').lang('he', { MM : "%d חודשים", y : "שנה", yy : "%d שנים" - }, - ordinal : function (number) { - return ''; // Function is not required for the Hebrew language. } }); diff --git a/lang/hu.js b/lang/hu.js index 475b0f060..93750017a 100644 --- a/lang/hu.js +++ b/lang/hu.js @@ -79,10 +79,7 @@ require('../moment').lang('hu', { y : translate, yy : translate }, - ordinal : function (number) { - return '.'; - - }, + ordinal : '%d.', week : { dow : 1, // Monday is the first day of the week. doy : 7 // The week that contains Jan 1st is the first week of the year. diff --git a/lang/id.js b/lang/id.js index f607b5546..1a27adb89 100644 --- a/lang/id.js +++ b/lang/id.js @@ -50,9 +50,6 @@ require('../moment').lang('id', { y : "setahun", yy : "%d tahun" }, - ordinal : function (number) { - return ''; - }, week : { dow : 1, // Monday is the first day of the week. doy : 7 // The week that contains Jan 1st is the first week of the year. diff --git a/lang/is.js b/lang/is.js index 5b8363353..8455e419f 100644 --- a/lang/is.js +++ b/lang/is.js @@ -106,9 +106,7 @@ require('../moment').lang('is', { y : translate, yy : translate }, - ordinal : function (number) { - return '.'; - }, + ordinal : '%d.', week : { dow : 1, // Monday is the first day of the week. doy : 4 // The week that contains Jan 4th is the first week of the year. diff --git a/lang/it.js b/lang/it.js index 851be3782..3166393fd 100644 --- a/lang/it.js +++ b/lang/it.js @@ -38,9 +38,7 @@ require('../moment').lang('it', { y : "un anno", yy : "%d anni" }, - ordinal: function () { - return 'º'; - }, + ordinal: '%dº', week : { dow : 1, // Monday is the first day of the week. doy : 4 // The week that contains Jan 4th is the first week of the year. diff --git a/lang/ja.js b/lang/ja.js index d5100fee2..84ce6e85a 100644 --- a/lang/ja.js +++ b/lang/ja.js @@ -44,8 +44,5 @@ require('../moment').lang('ja', { MM : "%dヶ月", y : "1年", yy : "%d年" - }, - ordinal : function (number) { - return ''; } }); diff --git a/lang/jp.js b/lang/jp.js index 804511bf5..6857365a8 100644 --- a/lang/jp.js +++ b/lang/jp.js @@ -47,8 +47,5 @@ require('../moment').lang('jp', { MM : "%dヶ月", y : "1年", yy : "%d年" - }, - ordinal : function (number) { - return ''; } }); diff --git a/lang/ko.js b/lang/ko.js index 76b1a93d4..7a59cb783 100644 --- a/lang/ko.js +++ b/lang/ko.js @@ -42,7 +42,5 @@ require('../moment').lang('ko', { y : "일년", yy : "%d년" }, - ordinal : function (number) { - return '일'; - } + ordinal : '%d일' }); diff --git a/lang/kr.js b/lang/kr.js index b702ca6b9..5ea9c0d2a 100644 --- a/lang/kr.js +++ b/lang/kr.js @@ -45,7 +45,5 @@ require('../moment').lang('kr', { y : "일년", yy : "%d년" }, - ordinal : function (number) { - return '일'; - } + ordinal : '%d일' }); diff --git a/lang/lv.js b/lang/lv.js index 48bfcb2a1..855ebead7 100644 --- a/lang/lv.js +++ b/lang/lv.js @@ -59,9 +59,7 @@ require('../moment').lang('lv', { y : "gadu", yy : relativeTimeWithPlural }, - ordinal : function (number) { - return '.'; - }, + ordinal : '%d.', week : { dow : 1, // Monday is the first day of the week. doy : 4 // The week that contains Jan 4th is the first week of the year. diff --git a/lang/nb.js b/lang/nb.js index 2cc3ae086..a39f8f5a9 100644 --- a/lang/nb.js +++ b/lang/nb.js @@ -38,9 +38,7 @@ require('../moment').lang('nb', { y : "ett år", yy : "%d år" }, - ordinal : function (number) { - return '.'; - }, + ordinal : '%d.', week : { dow : 1, // Monday is the first day of the week. doy : 4 // The week that contains Jan 4th is the first week of the year. diff --git a/lang/ne.js b/lang/ne.js index 16c95631d..6df9a9c5a 100644 --- a/lang/ne.js +++ b/lang/ne.js @@ -88,9 +88,6 @@ require('../moment').lang('ne', { y : "एक बर्ष", yy : "%d बर्ष" }, - ordinal : function (number) { - return ''; - }, week : { dow : 1, // Monday is the first day of the week. doy : 7 // The week that contains Jan 1st is the first week of the year. diff --git a/lang/nl.js b/lang/nl.js index 4b1480211..018990b40 100644 --- a/lang/nl.js +++ b/lang/nl.js @@ -48,7 +48,7 @@ require('../moment').lang('nl', { yy : "%d jaar" }, ordinal : function (number) { - return (number === 1 || number === 8 || number >= 20) ? 'ste' : 'de'; + return number + ((number === 1 || number === 8 || number >= 20) ? 'ste' : 'de'); }, week : { dow : 1, // Monday is the first day of the week. diff --git a/lang/pl.js b/lang/pl.js index 030ca39a2..51e231872 100644 --- a/lang/pl.js +++ b/lang/pl.js @@ -71,9 +71,7 @@ require('../moment').lang('pl', { y : "rok", yy : translate }, - ordinal : function (number) { - return '.'; - }, + ordinal : '%d.', week : { dow : 1, // Monday is the first day of the week. doy : 4 // The week that contains Jan 4th is the first week of the year. diff --git a/lang/pt-br.js b/lang/pt-br.js index 23600027a..2427097e1 100644 --- a/lang/pt-br.js +++ b/lang/pt-br.js @@ -42,7 +42,5 @@ require('../moment').lang('pt-br', { y : "um ano", yy : "%d anos" }, - ordinal : function (number) { - return 'º'; - } + ordinal : '%dº' }); diff --git a/lang/pt.js b/lang/pt.js index 594094bfc..b199b8e57 100644 --- a/lang/pt.js +++ b/lang/pt.js @@ -42,9 +42,7 @@ require('../moment').lang('pt', { y : "um ano", yy : "%d anos" }, - ordinal : function (number) { - return 'º'; - }, + ordinal : '%dº', week : { dow : 1, // Monday is the first day of the week. doy : 4 // The week that contains Jan 4th is the first week of the year. diff --git a/lang/ro.js b/lang/ro.js index ba35c674d..036c85baf 100644 --- a/lang/ro.js +++ b/lang/ro.js @@ -39,9 +39,6 @@ require('../moment').lang('ro', { y : "un an", yy : "%d ani" }, - ordinal : function (number) { - return ''; - }, week : { dow : 1, // Monday is the first day of the week. doy : 7 // The week that contains Jan 1st is the first week of the year. diff --git a/lang/ru.js b/lang/ru.js index 4be8616b3..73e169fb0 100644 --- a/lang/ru.js +++ b/lang/ru.js @@ -116,9 +116,7 @@ require('../moment').lang('ru', { y : "год", yy : relativeTimeWithPlural }, - ordinal : function (number) { - return '.'; - }, + ordinal : '%d.', week : { dow : 1, // Monday is the first day of the week. doy : 7 // The week that contains Jan 1st is the first week of the year. diff --git a/lang/sl.js b/lang/sl.js index 49c83db2d..a284f06a6 100644 --- a/lang/sl.js +++ b/lang/sl.js @@ -126,9 +126,7 @@ require('../moment').lang('sl', { y : "eno leto", yy : translate }, - ordinal : function (number) { - return '.'; - }, + ordinal : '%d.', week : { dow : 1, // Monday is the first day of the week. doy : 7 // The week that contains Jan 1st is the first week of the year. diff --git a/lang/sv.js b/lang/sv.js index 4359f5648..8b283d3b4 100644 --- a/lang/sv.js +++ b/lang/sv.js @@ -39,11 +39,12 @@ require('../moment').lang('sv', { yy : "%d år" }, ordinal : function (number) { - var b = number % 10; - return (~~ (number % 100 / 10) === 1) ? 'e' : + var b = number % 10, + output = (~~ (number % 100 / 10) === 1) ? 'e' : (b === 1) ? 'a' : (b === 2) ? 'a' : (b === 3) ? 'e' : 'e'; + return number + output; }, week : { dow : 1, // Monday is the first day of the week. diff --git a/lang/th.js b/lang/th.js index a01f7791e..d2699cd6f 100644 --- a/lang/th.js +++ b/lang/th.js @@ -44,8 +44,5 @@ require('../moment').lang('th', { MM : "%d เดือน", y : "1 ปี", yy : "%d ปี" - }, - ordinal : function (number) { - return ''; } }); diff --git a/lang/tr.js b/lang/tr.js index 617027e2d..731bfffb7 100644 --- a/lang/tr.js +++ b/lang/tr.js @@ -67,13 +67,13 @@ require('../moment').lang('tr', { }, ordinal : function (number) { if (number === 0) { // special case for zero - return "'ıncı"; + return number + "'ıncı"; } var a = number % 10, b = number % 100 - a, c = number >= 100 ? 100 : null; - return suffixes[a] || suffixes[b] || suffixes[c]; + return number + (suffixes[a] || suffixes[b] || suffixes[c]); }, week : { dow : 1, // Monday is the first day of the week. diff --git a/lang/tzm-la.js b/lang/tzm-la.js index af56946f1..870947ed5 100644 --- a/lang/tzm-la.js +++ b/lang/tzm-la.js @@ -38,9 +38,6 @@ require('../moment').lang('tzm-la', { y : "asgas", yy : "%d isgasn" }, - ordinal : function (number) { - return ''; - }, week : { dow : 6, // Saturday is the first day of the week. doy : 12 // The week that contains Jan 1st is the first week of the year. diff --git a/lang/tzm.js b/lang/tzm.js index 18fb4c578..cffb946c8 100644 --- a/lang/tzm.js +++ b/lang/tzm.js @@ -38,9 +38,6 @@ require('../moment').lang('tzm', { y : "ⴰⵙⴳⴰⵙ", yy : "%d ⵉⵙⴳⴰⵙⵏ" }, - ordinal : function (number) { - return ''; - }, week : { dow : 6, // Saturday is the first day of the week. doy : 12 // The week that contains Jan 1st is the first week of the year. diff --git a/lang/zh-cn.js b/lang/zh-cn.js index 85cd1d609..b322e0969 100644 --- a/lang/zh-cn.js +++ b/lang/zh-cn.js @@ -50,8 +50,5 @@ require('../moment').lang('zh-cn', { MM : "%d个月", y : "1年", yy : "%d年" - }, - ordinal : function (number) { - return ''; } }); diff --git a/lang/zh-tw.js b/lang/zh-tw.js index d9d80d470..e29bd2fde 100644 --- a/lang/zh-tw.js +++ b/lang/zh-tw.js @@ -50,8 +50,5 @@ require('../moment').lang('zh-tw', { MM : "%d個月", y : "一年", yy : "%d年" - }, - ordinal : function (number) { - return ''; } }); diff --git a/moment.js b/moment.js index 414fafdd3..be3d9ad08 100644 --- a/moment.js +++ b/moment.js @@ -171,8 +171,7 @@ } function ordinalizeToken(func) { return function (a) { - var b = func.call(this, a); - return b + this.lang().ordinal(b); + return this.lang().ordinal(func.call(this, a)); }; } @@ -444,8 +443,9 @@ }, ordinal : function (number) { - return ''; + return this._ordinal.replace("%d", number); }, + _ordinal : "%d", preparse : function (string) { return string; @@ -1324,11 +1324,12 @@ // Set default language, other languages will inherit from English. moment.lang('en', { ordinal : function (number) { - var b = number % 10; - return (~~ (number % 100 / 10) === 1) ? 'th' : + var b = number % 10, + output = (~~ (number % 100 / 10) === 1) ? 'th' : (b === 1) ? 'st' : (b === 2) ? 'nd' : (b === 3) ? 'rd' : 'th'; + return number + output; } }); -- 2.47.2