]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Fix Romanian plural names
authorAndrei Damian-Fekete <andrei@tehnica.org>
Fri, 1 Nov 2013 23:57:58 +0000 (00:57 +0100)
committerAndrei Damian-Fekete <andrei@tehnica.org>
Fri, 1 Nov 2013 23:57:58 +0000 (00:57 +0100)
"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
test/lang/ro.js

index c00086f71eaadb8f9f109184e6a3f6e64981accc..77d735558b1bb9ec55de6932cb4985ea2c9e268d 100644 (file)
         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("_"),
             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.
index a58d41fa756215d34b744d1b1ca8ed88710d60ad..2c42931a19cc70491de08b8a4578753453112617 100644 (file)
@@ -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();
     },