From: Valentin Agachi Date: Tue, 7 Aug 2012 19:56:58 +0000 (+0200) Subject: Romanian (ro) translation with tests X-Git-Tag: 1.7.1~5^2~2^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F388%2Fhead;p=thirdparty%2Fmoment.git Romanian (ro) translation with tests --- diff --git a/lang/ro.js b/lang/ro.js new file mode 100644 index 000000000..0856b395d --- /dev/null +++ b/lang/ro.js @@ -0,0 +1,55 @@ +// moment.js language configuration +// language : romanian (ro) +// author : Vlad Gurdiga : https://github.com/gurdiga +// author : Valentin Agachi : https://github.com/avaly +(function () { + var lang = { + 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("_"), + weekdays : "Duminică_Luni_Marţi_Miercuri_Joi_Vineri_Sâmbătă".split("_"), + weekdaysShort : "Dum_Lun_Mar_Mie_Joi_Vin_Sâm".split("_"), + weekdaysMin : "Du_Lu_Ma_Mi_Jo_Vi_Sâ".split("_"), + longDateFormat : { + LT : "H:mm", + L : "DD/MM/YYYY", + LL : "D MMMM YYYY", + LLL : "D MMMM YYYY H:mm", + LLLL : "dddd, D MMMM YYYY H:mm" + }, + calendar : { + sameDay: "[azi la] LT", + nextDay: '[mâine la] LT', + nextWeek: 'dddd [la] LT', + lastDay: '[ieri la] LT', + lastWeek: '[fosta] dddd [la] LT', + sameElse: 'L' + }, + relativeTime : { + future : "peste %s", + past : "%s în urmă", + s : "câteva secunde", + m : "un minut", + mm : "%d minute", + h : "o oră", + hh : "%d ore", + d : "o zi", + dd : "%d zile", + M : "o lună", + MM : "%d luni", + y : "un an", + yy : "%d ani" + }, + ordinal : function (number) { + return ''; + } + }; + + // Node + if (typeof module !== 'undefined') { + module.exports = lang; + } + // Browser + if (typeof window !== 'undefined' && this.moment && this.moment.lang) { + this.moment.lang('ro', lang); + } +}()); diff --git a/test/lang/ro.js b/test/lang/ro.js new file mode 100644 index 000000000..1773584e3 --- /dev/null +++ b/test/lang/ro.js @@ -0,0 +1,248 @@ +var moment = require("../../moment"); + + + /************************************************** + Romanian + *************************************************/ + +exports["lang:ro"] = { + "parse" : function(test) { + test.expect(96); + moment.lang('ro'); + var tests = 'Ianuarie Ian_Februarie Feb_Martie Mar_Aprilie Apr_Mai Mai_Iunie Iun_Iulie Iul_August Aug_Septembrie Sep_Octombrie Oct_Noiembrie Noi_Decembrie Dec'.split("_"); + var i; + function equalTest(input, mmm, i) { + test.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.done(); + }, + + "format" : function(test) { + test.expect(18); + moment.lang('ro'); + var a = [ + ['dddd, MMMM Do YYYY, h:mm:ss A', 'Duminică, Februarie 14 2010, 3:25:50 PM'], + ['ddd, hA', 'Dum, 3PM'], + ['M Mo MM MMMM MMM', '2 2 02 Februarie Feb'], + ['YYYY YY', '2010 10'], + ['D Do DD', '14 14 14'], + ['d do dddd ddd dd', '0 0 Duminică Dum Du'], + ['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', 'pm PM'], + ['\\a DDDo\\a zi \\a \\anului', 'a 45a zi a anului'], + ['L', '14/02/2010'], + ['LL', '14 Februarie 2010'], + ['LLL', '14 Februarie 2010 15:25'], + ['LLLL', 'Duminică, 14 Februarie 2010 15:25'] + ], + b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)), + i; + for (i = 0; i < a.length; i++) { + test.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]); + } + test.done(); + }, + + "format ordinal" : function(test) { + test.expect(31); + moment.lang('ro'); + test.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1'); + test.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2'); + test.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3'); + test.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4'); + test.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5'); + test.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6'); + test.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7'); + test.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8'); + test.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9'); + test.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10'); + + test.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11'); + test.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12'); + test.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13'); + test.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14'); + test.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15'); + test.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16'); + test.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17'); + test.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18'); + test.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19'); + test.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20'); + + test.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21'); + test.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22'); + test.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23'); + test.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24'); + test.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25'); + test.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26'); + test.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27'); + test.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28'); + test.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29'); + test.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30'); + + test.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31'); + test.done(); + }, + + "format month" : function(test) { + test.expect(12); + moment.lang('ro'); + var expected = 'Ianuarie Ian_Februarie Feb_Martie Mar_Aprilie Apr_Mai Mai_Iunie Iun_Iulie Iul_August Aug_Septembrie Sep_Octombrie Oct_Noiembrie Noi_Decembrie Dec'.split("_"); + var i; + for (i = 0; i < expected.length; i++) { + test.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]); + } + test.done(); + }, + + "format week" : function(test) { + test.expect(7); + moment.lang('ro'); + var expected = 'Duminică Dum Du_Luni Lun Lu_Marţi Mar Ma_Miercuri Mie Mi_Joi Joi Jo_Vineri Vin Vi_Sâmbătă Sâm Sâ'.split("_"); + var i; + for (i = 0; i < expected.length; i++) { + test.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]); + } + test.done(); + }, + + "from" : function(test) { + test.expect(30); + moment.lang('ro'); + 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: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: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: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ă"); + test.equal(start.from(moment([2007, 1, 28]).add({d:46}), true), "2 luni", "46 zile = 2 luni"); + test.equal(start.from(moment([2007, 1, 28]).add({d:74}), true), "2 luni", "75 zile = 2 luni"); + test.equal(start.from(moment([2007, 1, 28]).add({d:76}), true), "3 luni", "76 zile = 3 luni"); + test.equal(start.from(moment([2007, 1, 28]).add({M:1}), true), "o lună", "1 lună = o lună"); + test.equal(start.from(moment([2007, 1, 28]).add({M:5}), true), "5 luni", "5 luni = 5 luni"); + test.equal(start.from(moment([2007, 1, 28]).add({d:344}), true), "11 luni", "344 zile = 11 luni"); + test.equal(start.from(moment([2007, 1, 28]).add({d:345}), true), "un an", "345 zile = un an"); + test.equal(start.from(moment([2007, 1, 28]).add({d:547}), true), "un an", "547 zile = un an"); + 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.done(); + }, + + "suffix" : function(test) { + test.expect(2); + moment.lang('ro'); + test.equal(moment(30000).from(0), "peste câteva secunde", "prefix"); + test.equal(moment(0).from(30000), "câteva secunde în urmă", "suffix"); + test.done(); + }, + + "now from now" : function(test) { + test.expect(1); + moment.lang('ro'); + test.equal(moment().fromNow(), "câteva secunde în urmă", "now from now should display as in the past"); + test.done(); + }, + + "fromNow" : function(test) { + test.expect(2); + moment.lang('ro'); + test.equal(moment().add({s:30}).fromNow(), "peste câteva secunde", "in a few seconds"); + test.equal(moment().add({d:5}).fromNow(), "peste 5 zile", "in 5 days"); + test.done(); + }, + + "calendar day" : function(test) { + test.expect(6); + moment.lang('ro'); + + var a = moment().hours(2).minutes(0).seconds(0); + + test.equal(moment(a).calendar(), "azi la 2:00", "today at the same time"); + test.equal(moment(a).add({ m: 25 }).calendar(), "azi la 2:25", "Now plus 25 min"); + test.equal(moment(a).add({ h: 1 }).calendar(), "azi la 3:00", "Now plus 1 hour"); + test.equal(moment(a).add({ d: 1 }).calendar(), "mâine la 2:00", "tomorrow at the same time"); + test.equal(moment(a).subtract({ h: 1 }).calendar(), "azi la 1:00", "Now minus 1 hour"); + test.equal(moment(a).subtract({ d: 1 }).calendar(), "ieri la 2:00", "yesterday at the same time"); + test.done(); + }, + + "calendar next week" : function(test) { + test.expect(15); + moment.lang('ro'); + + var i; + var m; + + for (i = 2; i < 7; i++) { + m = moment().add({ d: i }); + test.equal(m.calendar(), m.format('dddd [la] LT'), "Today + " + i + " days current time"); + m.hours(0).minutes(0).seconds(0).milliseconds(0); + test.equal(m.calendar(), m.format('dddd [la] LT'), "Today + " + i + " days beginning of day"); + m.hours(23).minutes(59).seconds(59).milliseconds(999); + test.equal(m.calendar(), m.format('dddd [la] LT'), "Today + " + i + " days end of day"); + } + test.done(); + }, + + "calendar last week" : function(test) { + test.expect(15); + moment.lang('ro'); + + for (i = 2; i < 7; i++) { + m = moment().subtract({ d: i }); + test.equal(m.calendar(), m.format('[fosta] dddd [la] LT'), "Today - " + i + " days current time"); + m.hours(0).minutes(0).seconds(0).milliseconds(0); + test.equal(m.calendar(), m.format('[fosta] dddd [la] LT'), "Today - " + i + " days beginning of day"); + m.hours(23).minutes(59).seconds(59).milliseconds(999); + test.equal(m.calendar(), m.format('[fosta] dddd [la] LT'), "Today - " + i + " days end of day"); + } + test.done(); + }, + + "calendar all else" : function(test) { + test.expect(4); + moment.lang('ro'); + var weeksAgo = moment().subtract({ w: 1 }); + var weeksFromNow = moment().add({ w: 1 }); + + test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 week ago"); + test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 1 week"); + + weeksAgo = moment().subtract({ w: 2 }); + weeksFromNow = moment().add({ w: 2 }); + + test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago"); + test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks"); + test.done(); + } +};