From: Suhail Alkowaileet Date: Thu, 27 Mar 2014 16:59:48 +0000 (+0300) Subject: Updating Arabic language and minimize weekdaysShort X-Git-Tag: 2.7.0~24^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2cbad13c00ceadd192fd3d72c93eb5c1831e8dfa;p=thirdparty%2Fmoment.git Updating Arabic language and minimize weekdaysShort --- diff --git a/lang/ar.js b/lang/ar.js index 6e27d29a9..dd01a42cf 100644 --- a/lang/ar.js +++ b/lang/ar.js @@ -12,11 +12,35 @@ factory(window.moment); // Browser global } }(function (moment) { + var symbolMap = { + '1': '١', + '2': '٢', + '3': '٣', + '4': '٤', + '5': '٥', + '6': '٦', + '7': '٧', + '8': '٨', + '9': '٩', + '0': '٠' + }, numberMap = { + '١': '1', + '٢': '2', + '٣': '3', + '٤': '4', + '٥': '5', + '٦': '6', + '٧': '7', + '٨': '8', + '٩': '9', + '٠': '0' + }; + return moment.lang('ar', { months : "يناير/ كانون الثاني_فبراير/ شباط_مارس/ آذار_أبريل/ نيسان_مايو/ أيار_يونيو/ حزيران_يوليو/ تموز_أغسطس/ آب_سبتمبر/ أيلول_أكتوبر/ تشرين الأول_نوفمبر/ تشرين الثاني_ديسمبر/ كانون الأول".split("_"), monthsShort : "يناير/ كانون الثاني_فبراير/ شباط_مارس/ آذار_أبريل/ نيسان_مايو/ أيار_يونيو/ حزيران_يوليو/ تموز_أغسطس/ آب_سبتمبر/ أيلول_أكتوبر/ تشرين الأول_نوفمبر/ تشرين الثاني_ديسمبر/ كانون الأول".split("_"), weekdays : "الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"), - weekdaysShort : "الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"), + weekdaysShort : "أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت".split("_"), weekdaysMin : "ح_ن_ث_ر_خ_ج_س".split("_"), longDateFormat : { LT : "HH:mm", @@ -25,6 +49,13 @@ LLL : "D MMMM YYYY LT", LLLL : "dddd D MMMM YYYY LT" }, + meridiem : function (hour, minute, isLower) { + if (hour < 12) { + return "ص"; + } else { + return "م"; + } + }, calendar : { sameDay: "[اليوم على الساعة] LT", nextDay: '[غدا على الساعة] LT', @@ -48,6 +79,16 @@ y : "سنة", yy : "%d سنوات" }, + preparse: function (string) { + return string.replace(/[۰-۹]/g, function (match) { + return numberMap[match]; + }).replace(/،/g, ','); + }, + postformat: function (string) { + return string.replace(/\d/g, function (match) { + return symbolMap[match]; + }).replace(/,/g, '،'); + }, 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/test/lang/ar.js b/test/lang/ar.js index 098b802e2..fb85fbf70 100644 --- a/test/lang/ar.js +++ b/test/lang/ar.js @@ -36,28 +36,28 @@ exports["lang:ar"] = { "format" : function (test) { test.expect(22); var a = [ - ['dddd, MMMM Do YYYY, h:mm:ss a', 'الأحد, فبراير/ شباط 14 2010, 3:25:50 pm'], - ['ddd, hA', 'الأحد, 3PM'], - ['M Mo MM MMMM MMM', '2 2 02 فبراير/ شباط فبراير/ شباط'], - ['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', 'pm PM'], - ['[the] DDDo [day of the year]', 'the 45 day of the year'], - ['L', '14/02/2010'], - ['LL', '14 فبراير/ شباط 2010'], - ['LLL', '14 فبراير/ شباط 2010 15:25'], - ['LLLL', 'الأحد 14 فبراير/ شباط 2010 15:25'], - ['l', '14/2/2010'], - ['ll', '14 فبراير/ شباط 2010'], - ['lll', '14 فبراير/ شباط 2010 15:25'], - ['llll', 'الأحد 14 فبراير/ شباط 2010 15:25'] + ['dddd, MMMM Do YYYY, h:mm:ss a', 'الأحد، فبراير/ شباط ١٤ ٢٠١٠، ٣:٢٥:٥٠ م'], + ['ddd, hA', 'أحد، ٣م'], + ['M Mo MM MMMM MMM', '٢ ٢ ٠٢ فبراير/ شباط فبراير/ شباط'], + ['YYYY YY', '٢٠١٠ ١٠'], + ['D Do DD', '١٤ ١٤ ١٤'], + ['d do dddd ddd dd', '٠ ٠ الأحد أحد ح'], + ['DDD DDDo DDDD', '٤٥ ٤٥ ٠٤٥'], + ['w wo ww', '٨ ٨ ٠٨'], + ['h hh', '٣ ٠٣'], + ['H HH', '١٥ ١٥'], + ['m mm', '٢٥ ٢٥'], + ['s ss', '٥٠ ٥٠'], + ['a A', 'م م'], + ['[the] DDDo [day of the year]', 'the ٤٥ day of the year'], + ['L', '١٤/٠٢/٢٠١٠'], + ['LL', '١٤ فبراير/ شباط ٢٠١٠'], + ['LLL', '١٤ فبراير/ شباط ٢٠١٠ ١٥:٢٥'], + ['LLLL', 'الأحد ١٤ فبراير/ شباط ٢٠١٠ ١٥:٢٥'], + ['l', '١٤/٢/٢٠١٠'], + ['ll', '١٤ فبراير/ شباط ٢٠١٠'], + ['lll', '١٤ فبراير/ شباط ٢٠١٠ ١٥:٢٥'], + ['llll', 'أحد ١٤ فبراير/ شباط ٢٠١٠ ١٥:٢٥'] ], b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)), i; @@ -69,40 +69,40 @@ exports["lang:ar"] = { "format ordinal" : function (test) { test.expect(31); - 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.equal(moment([2011, 0, 1]).format('DDDo'), '١', '1'); + test.equal(moment([2011, 0, 2]).format('DDDo'), '٢', '2'); + test.equal(moment([2011, 0, 3]).format('DDDo'), '٣', '3'); + test.equal(moment([2011, 0, 4]).format('DDDo'), '٤', '4'); + test.equal(moment([2011, 0, 5]).format('DDDo'), '٥', '5'); + test.equal(moment([2011, 0, 6]).format('DDDo'), '٦', '6'); + test.equal(moment([2011, 0, 7]).format('DDDo'), '٧', '7'); + test.equal(moment([2011, 0, 8]).format('DDDo'), '٨', '8'); + test.equal(moment([2011, 0, 9]).format('DDDo'), '٩', '9'); + test.equal(moment([2011, 0, 10]).format('DDDo'), '١٠', '10'); + + test.equal(moment([2011, 0, 11]).format('DDDo'), '١١', '11'); + test.equal(moment([2011, 0, 12]).format('DDDo'), '١٢', '12'); + test.equal(moment([2011, 0, 13]).format('DDDo'), '١٣', '13'); + test.equal(moment([2011, 0, 14]).format('DDDo'), '١٤', '14'); + test.equal(moment([2011, 0, 15]).format('DDDo'), '١٥', '15'); + test.equal(moment([2011, 0, 16]).format('DDDo'), '١٦', '16'); + test.equal(moment([2011, 0, 17]).format('DDDo'), '١٧', '17'); + test.equal(moment([2011, 0, 18]).format('DDDo'), '١٨', '18'); + test.equal(moment([2011, 0, 19]).format('DDDo'), '١٩', '19'); + test.equal(moment([2011, 0, 20]).format('DDDo'), '٢٠', '20'); + + test.equal(moment([2011, 0, 21]).format('DDDo'), '٢١', '21'); + test.equal(moment([2011, 0, 22]).format('DDDo'), '٢٢', '22'); + test.equal(moment([2011, 0, 23]).format('DDDo'), '٢٣', '23'); + test.equal(moment([2011, 0, 24]).format('DDDo'), '٢٤', '24'); + test.equal(moment([2011, 0, 25]).format('DDDo'), '٢٥', '25'); + test.equal(moment([2011, 0, 26]).format('DDDo'), '٢٦', '26'); + test.equal(moment([2011, 0, 27]).format('DDDo'), '٢٧', '27'); + test.equal(moment([2011, 0, 28]).format('DDDo'), '٢٨', '28'); + test.equal(moment([2011, 0, 29]).format('DDDo'), '٢٩', '29'); + test.equal(moment([2011, 0, 30]).format('DDDo'), '٣٠', '30'); + + test.equal(moment([2011, 0, 31]).format('DDDo'), '٣١', '31'); test.done(); }, @@ -119,7 +119,7 @@ exports["lang:ar"] = { "format week" : function (test) { test.expect(7); - var expected = 'الأحد الأحد ح_الإثنين الإثنين ن_الثلاثاء الثلاثاء ث_الأربعاء الأربعاء ر_الخميس الخميس خ_الجمعة الجمعة ج_السبت السبت س'.split("_"), i; + var expected = 'الأحد أحد ح_الإثنين إثنين ن_الثلاثاء ثلاثاء ث_الأربعاء أربعاء ر_الخميس خميس خ_الجمعة جمعة ج_السبت سبت س'.split("_"), i; for (i = 0; i < expected.length; i++) { test.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]); } @@ -133,33 +133,33 @@ exports["lang:ar"] = { test.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), "ثوان", "44 seconds = a few seconds"); test.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), "دقيقة", "45 seconds = a minute"); test.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), "دقيقة", "89 seconds = a minute"); - test.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), "2 دقائق", "90 seconds = 2 minutes"); - test.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), "44 دقائق", "44 minutes = 44 minutes"); + test.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), "٢ دقائق", "90 seconds = 2 minutes"); + test.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), "٤٤ دقائق", "44 minutes = 44 minutes"); test.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), "ساعة", "45 minutes = an hour"); test.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), "ساعة", "89 minutes = an hour"); - test.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), "2 ساعات", "90 minutes = 2 hours"); - test.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), "5 ساعات", "5 hours = 5 hours"); - test.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), "21 ساعات", "21 hours = 21 hours"); + test.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), "٢ ساعات", "90 minutes = 2 hours"); + test.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), "٥ ساعات", "5 hours = 5 hours"); + test.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), "٢١ ساعات", "21 hours = 21 hours"); test.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), "يوم", "22 hours = a day"); test.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), "يوم", "35 hours = a day"); - test.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), "2 أيام", "36 hours = 2 days"); + test.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), "٢ أيام", "36 hours = 2 days"); test.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), "يوم", "1 day = a day"); - test.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), "5 أيام", "5 days = 5 days"); - test.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), "25 أيام", "25 days = 25 days"); + test.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), "٥ أيام", "5 days = 5 days"); + test.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), "٢٥ أيام", "25 days = 25 days"); test.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), "شهر", "26 days = a month"); test.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), "شهر", "30 days = a month"); test.equal(start.from(moment([2007, 1, 28]).add({d: 45}), true), "شهر", "45 days = a month"); - test.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), "2 أشهر", "46 days = 2 months"); - test.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), "2 أشهر", "75 days = 2 months"); - test.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), "3 أشهر", "76 days = 3 months"); + test.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), "٢ أشهر", "46 days = 2 months"); + test.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), "٢ أشهر", "75 days = 2 months"); + test.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), "٣ أشهر", "76 days = 3 months"); test.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), "شهر", "1 month = a month"); - test.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), "5 أشهر", "5 months = 5 months"); - test.equal(start.from(moment([2007, 1, 28]).add({d: 344}), true), "11 أشهر", "344 days = 11 months"); + test.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), "٥ أشهر", "5 months = 5 months"); + test.equal(start.from(moment([2007, 1, 28]).add({d: 344}), true), "١١ أشهر", "344 days = 11 months"); test.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), "سنة", "345 days = a year"); test.equal(start.from(moment([2007, 1, 28]).add({d: 547}), true), "سنة", "547 days = a year"); - test.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), "2 سنوات", "548 days = 2 years"); + test.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), "٢ سنوات", "548 days = 2 years"); test.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), "سنة", "1 year = a year"); - test.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), "5 سنوات", "5 years = 5 years"); + test.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), "٥ سنوات", "5 years = 5 years"); test.done(); }, @@ -179,7 +179,7 @@ exports["lang:ar"] = { "fromNow" : function (test) { test.expect(2); test.equal(moment().add({s: 30}).fromNow(), "في ثوان", "in a few seconds"); - test.equal(moment().add({d: 5}).fromNow(), "في 5 أيام", "in 5 days"); + test.equal(moment().add({d: 5}).fromNow(), "في ٥ أيام", "in 5 days"); test.done(); }, @@ -188,12 +188,12 @@ exports["lang:ar"] = { var a = moment().hours(2).minutes(0).seconds(0); - test.equal(moment(a).calendar(), "اليوم على الساعة 02:00", "today at the same time"); - test.equal(moment(a).add({ m: 25 }).calendar(), "اليوم على الساعة 02:25", "Now plus 25 min"); - test.equal(moment(a).add({ h: 1 }).calendar(), "اليوم على الساعة 03:00", "Now plus 1 hour"); - test.equal(moment(a).add({ d: 1 }).calendar(), "غدا على الساعة 02:00", "tomorrow at the same time"); - test.equal(moment(a).subtract({ h: 1 }).calendar(), "اليوم على الساعة 01:00", "Now minus 1 hour"); - test.equal(moment(a).subtract({ d: 1 }).calendar(), "أمس على الساعة 02:00", "yesterday at the same time"); + test.equal(moment(a).calendar(), "اليوم على الساعة ٠٢:٠٠", "today at the same time"); + test.equal(moment(a).add({ m: 25 }).calendar(), "اليوم على الساعة ٠٢:٢٥", "Now plus 25 min"); + test.equal(moment(a).add({ h: 1 }).calendar(), "اليوم على الساعة ٠٣:٠٠", "Now plus 1 hour"); + test.equal(moment(a).add({ d: 1 }).calendar(), "غدا على الساعة ٠٢:٠٠", "tomorrow at the same time"); + test.equal(moment(a).subtract({ h: 1 }).calendar(), "اليوم على الساعة ٠١:٠٠", "Now minus 1 hour"); + test.equal(moment(a).subtract({ d: 1 }).calendar(), "أمس على الساعة ٠٢:٠٠", "yesterday at the same time"); test.done(); }, @@ -295,10 +295,10 @@ exports["lang:ar"] = { test.equal(moment([2003, 0, 10]).week(), 2, "Jan 10 2003 should be week 2"); test.equal(moment([2003, 0, 11]).week(), 3, "Jan 11 2003 should be week 3"); - test.equal(moment("2003 1 6", "gggg w d").format("YYYY-MM-DD"), "2002-12-28", "Week 1 of 2003 should be Dec 28 2002"); - test.equal(moment("2003 1 0", "gggg w e").format("YYYY-MM-DD"), "2002-12-28", "Week 1 of 2003 should be Dec 28 2002"); - test.equal(moment("2003 1 6", "gggg w d").format("gggg w d"), "2003 1 6", "Saturday of week 1 of 2003 parsed should be formatted as 2003 1 6"); - test.equal(moment("2003 1 0", "gggg w e").format("gggg w e"), "2003 1 0", "1st day of week 1 of 2003 parsed should be formatted as 2003 1 0"); + test.equal(moment("2003 1 6", "gggg w d").format("YYYY-MM-DD"), "٢٠٠٢-١٢-٢٨", "Week 1 of 2003 should be Dec 28 2002"); + test.equal(moment("2003 1 0", "gggg w e").format("YYYY-MM-DD"), "٢٠٠٢-١٢-٢٨", "Week 1 of 2003 should be Dec 28 2002"); + test.equal(moment("2003 1 6", "gggg w d").format("gggg w d"), "٢٠٠٣ ١ ٦", "Saturday of week 1 of 2003 parsed should be formatted as 2003 1 6"); + test.equal(moment("2003 1 0", "gggg w e").format("gggg w e"), "٢٠٠٣ ١ ٠", "1st day of week 1 of 2003 parsed should be formatted as 2003 1 0"); test.done(); }, @@ -343,11 +343,11 @@ exports["lang:ar"] = { "weeks year starting sunday formatted" : function (test) { test.expect(5); - test.equal(moment([2011, 11, 31]).format('w ww wo'), '1 01 1', "Dec 31 2011 should be week 1"); - test.equal(moment([2012, 0, 6]).format('w ww wo'), '1 01 1', "Jan 6 2012 should be week 1"); - test.equal(moment([2012, 0, 7]).format('w ww wo'), '2 02 2', "Jan 7 2012 should be week 2"); - test.equal(moment([2012, 0, 13]).format('w ww wo'), '2 02 2', "Jan 13 2012 should be week 2"); - test.equal(moment([2012, 0, 14]).format('w ww wo'), '3 03 3', "Jan 14 2012 should be week 3"); + test.equal(moment([2011, 11, 31]).format('w ww wo'), '١ ٠١ ١', "Dec 31 2011 should be week 1"); + test.equal(moment([2012, 0, 6]).format('w ww wo'), '١ ٠١ ١', "Jan 6 2012 should be week 1"); + test.equal(moment([2012, 0, 7]).format('w ww wo'), '٢ ٠٢ ٢', "Jan 7 2012 should be week 2"); + test.equal(moment([2012, 0, 13]).format('w ww wo'), '٢ ٠٢ ٢', "Jan 13 2012 should be week 2"); + test.equal(moment([2012, 0, 14]).format('w ww wo'), '٣ ٠٣ ٣', "Jan 14 2012 should be week 3"); test.done(); },