From e5bb720882a81de84ecba88f45eea961ff6d2f72 Mon Sep 17 00:00:00 2001 From: Andrei Damian-Fekete Date: Sat, 2 Nov 2013 00:57:58 +0100 Subject: [PATCH] Fix Romanian plural names "Syntactically, when a cardinal number determines a noun and when the number has certain values, the preposition de (roughly equivalent to of) is inserted between the number name and the modified noun in a way similar to English hundreds of birds" ( http://en.wikipedia.org/wiki/Romanian_numbers#Preposition_de ) --- lang/ro.js | 26 +++++++++++++++++++++----- test/lang/ro.js | 16 ++++++++++++---- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/lang/ro.js b/lang/ro.js index c00086f71..77d735558 100644 --- a/lang/ro.js +++ b/lang/ro.js @@ -12,6 +12,22 @@ factory(window.moment); // Browser global } }(function (moment) { + function relativeTimeWithPlural(number, withoutSuffix, key) { + var format = { + 'mm': 'minute', + 'hh': 'ore', + 'dd': 'zile', + 'MM': 'luni', + 'yy': 'ani' + }, + separator = ' '; + if (number % 100 >= 20 || (number >= 100 && number % 100 === 0)) { + separator = ' de '; + } + + return number + separator + format[key]; + } + return moment.lang('ro', { months : "ianuarie_februarie_martie_aprilie_mai_iunie_iulie_august_septembrie_octombrie_noiembrie_decembrie".split("_"), monthsShort : "ian_feb_mar_apr_mai_iun_iul_aug_sep_oct_noi_dec".split("_"), @@ -38,15 +54,15 @@ past : "%s în urmă", s : "câteva secunde", m : "un minut", - mm : "%d minute", + mm : relativeTimeWithPlural, h : "o oră", - hh : "%d ore", + hh : relativeTimeWithPlural, d : "o zi", - dd : "%d zile", + dd : relativeTimeWithPlural, M : "o lună", - MM : "%d luni", + MM : relativeTimeWithPlural, y : "un an", - yy : "%d ani" + yy : relativeTimeWithPlural }, week : { dow : 1, // Monday is the first day of the week. diff --git a/test/lang/ro.js b/test/lang/ro.js index a58d41fa7..2c42931a1 100644 --- a/test/lang/ro.js +++ b/test/lang/ro.js @@ -133,25 +133,25 @@ exports["lang:ro"] = { }, "from" : function (test) { - test.expect(30); + test.expect(38); var start = moment([2007, 1, 28]); test.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), "câteva secunde", "44 secunde = câteva secunde"); test.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), "un minut", "45 secunde = un minut"); test.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), "un minut", "89 secunde = un minut"); test.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), "2 minute", "90 secunde = 2 minute"); - test.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), "44 minute", "44 minute = 44 minute"); + test.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), "44 de minute", "44 minute = 44 minute"); test.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), "o oră", "45 minute = o oră"); test.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), "o oră", "89 minute = o oră"); test.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), "2 ore", "90 minute = 2 ore"); test.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), "5 ore", "5 ore = 5 ore"); - test.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), "21 ore", "21 ore = 21 ore"); + test.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), "21 de ore", "21 ore = 21 ore"); test.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), "o zi", "22 ore = o zi"); test.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), "o zi", "35 ore = o zi"); test.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), "2 zile", "36 ore = 2 zile"); test.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), "o zi", "1 zi = o zi"); test.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), "5 zile", "5 zile = 5 zile"); - test.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), "25 zile", "25 zile = 25 zile"); + test.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), "25 de zile", "25 zile = 25 zile"); test.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), "o lună", "26 zile = o lună"); test.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), "o lună", "30 zile = o lună"); test.equal(start.from(moment([2007, 1, 28]).add({d: 45}), true), "o lună", "45 zile = o lună"); @@ -166,6 +166,14 @@ exports["lang:ro"] = { test.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), "2 ani", "548 zile = 2 ani"); test.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), "un an", "1 an = un an"); test.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), "5 ani", "5 ani = 5 ani"); + test.equal(start.from(moment([2007, 1, 28]).add({y: 19}), true), "19 ani", "19 ani = 19 ani"); + test.equal(start.from(moment([2007, 1, 28]).add({y: 20}), true), "20 de ani", "20 ani = 20 ani"); + test.equal(start.from(moment([2007, 1, 28]).add({y: 100}), true), "100 de ani", "100 ani = 100 ani"); + test.equal(start.from(moment([2007, 1, 28]).add({y: 101}), true), "101 ani", "101 ani = 101 ani"); + test.equal(start.from(moment([2007, 1, 28]).add({y: 119}), true), "119 ani", "119 ani = 119 ani"); + test.equal(start.from(moment([2007, 1, 28]).add({y: 120}), true), "120 de ani", "120 ani = 120 ani"); + test.equal(start.from(moment([2007, 1, 28]).add({y: 219}), true), "219 ani", "219 ani = 219 ani"); + test.equal(start.from(moment([2007, 1, 28]).add({y: 220}), true), "220 de ani", "220 ani = 220 ani"); test.done(); }, -- 2.47.2