Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 87 additions & 10 deletions demos/datepicker/jquery.ui.datepicker-ar.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,100 @@
/* Arabic Translation for jQuery UI date picker plugin. */
/* Khaled Alhourani -- me@khaledalhourani.com */
/* NOTE: monthNames are the original months names and they are the Arabic names, not the new months name فبراير - يناير and there isn't any Arabic roots for these months */
/* Mohammad Hasani Eghtedar -- m.h.eghtedar@gmail.com */
/* Hijri calender supported */
jQuery(function($){
$.datepicker.regional['ar'] = {
calendar: HijriDate,
closeText: 'إغلاق',
prevText: '<السابق',
nextText: 'التالي>',
prevText: 'السابق',
nextText: 'التالي',
currentText: 'اليوم',
monthNames: ['كانون الثاني', 'شباط', 'آذار', 'نيسان', 'مايو', 'حزيران',
'تموز', 'آب', 'أيلول', 'تشرين الأول', 'تشرين الثاني', 'كانون الأول'],
monthNames: ['محرّم', 'صفر', 'ربيع الأول', 'ربيع الثاني', 'جمادى الأولى', 'جمادى الآخرة', 'رجب', 'شعبان', 'رمضان', 'شوال', 'ذو القعدة', 'ذو الحجة'],
monthNamesShort: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'],
dayNames: ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
dayNamesShort: ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
dayNamesShort: ['أحد', 'اثنين', 'ثلاثاء', 'أربعاء', 'خميس', 'جمعة', 'سبت'],
dayNamesMin: ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
weekHeader: 'أسبوع',
weekHeader: 'س',
dateFormat: 'dd/mm/yy',
firstDay: 6,
isRTL: true,
isRTL: true,
showMonthAfterYear: false,
yearSuffix: ''};
yearSuffix: '',
calculateWeek: function(date) {
var checkDate = new HijriDate(date.getFullYear(), date.getMonth(), date.getDate() + (date.getDay() || 7) - 3);
return Math.floor(Math.round((checkDate.getTime() - new HijriDate(checkDate.getFullYear(), 0, 1).getTime()) / 86400000) / 7) + 1;
}};
$.datepicker.setDefaults($.datepicker.regional['ar']);
});

function HijriDate(p0, p1, p2) {
var gregorianDate;
var hijriDate;

if (!isNaN(parseInt(p0)) && !isNaN(parseInt(p1)) && !isNaN(parseInt(p2))) {
var g = hijri_to_gregorian([parseInt(p0, 10), parseInt(p1, 10), parseInt(p2, 10)]);
setFullDate(new Date(g[0], g[1], g[2]));
} else {
setFullDate(p0);
}

function hijri_to_gregorian(d) {
var gregorian = jd_to_gregorian(islamic_to_jd(d[0], d[1] + 1, d[2]));
gregorian[1]--;
return gregorian;
}

function gregorian_to_hijri(d) {
var hijri = jd_to_islamic(gregorian_to_jd(d[0], d[1] + 1, d[2]));
hijri[1]--;
return hijri;
}

function setFullDate(date) {
if (date && date.getGregorianDate) date = date.getGregorianDate();
gregorianDate = new Date(date);
gregorianDate.setHours(gregorianDate.getHours() > 12 ? gregorianDate.getHours() + 2 : 0)
if (!gregorianDate || gregorianDate == 'Invalid Date' || isNaN(gregorianDate || !gregorianDate.getDate())) {
gregorianDate = new Date();
}
hijriDate = gregorian_to_hijri([
gregorianDate.getFullYear(),
gregorianDate.getMonth(),
gregorianDate.getDate()]);
return this;
}

this.getGregorianDate = function() { return gregorianDate; }

this.setFullDate = setFullDate;

this.setMonth = function(e) {
hijriDate[1] = e;
var g = hijri_to_gregorian(hijriDate);
gregorianDate = new Date(g[0], g[1], g[2]);
hijriDate = gregorian_to_hijri([g[0], g[1], g[2]]);
}

this.setDate = function(e) {
hijriDate[2] = e;
var g = hijri_to_gregorian(hijriDate);
gregorianDate = new Date(g[0], g[1], g[2]);
hijriDate = gregorian_to_hijri([g[0], g[1], g[2]]);
};

this.getFullYear = function() { return hijriDate[0]; };
this.getMonth = function() { return hijriDate[1]; };
this.getDate = function() { return hijriDate[2]; };
this.toString = function() { return hijriDate.join(',').toString(); };
this.getDay = function() { return gregorianDate.getDay(); };
this.getHours = function() { return gregorianDate.getHours(); };
this.getMinutes = function() { return gregorianDate.getMinutes(); };
this.getSeconds = function() { return gregorianDate.getSeconds(); };
this.getTime = function() { return gregorianDate.getTime(); };
this.getTimeZoneOffset = function() { return gregorianDate.getTimeZoneOffset(); };
this.getYear = function() { return hijriDate[0] % 100; };

this.setHours = function(e) { gregorianDate.setHours(e) };
this.setMinutes = function(e) { gregorianDate.setMinutes(e) };
this.setSeconds = function(e) { gregorianDate.setSeconds(e) };
this.setMilliseconds = function(e) { gregorianDate.setMilliseconds(e) };
}
142 changes: 142 additions & 0 deletions demos/datepicker/jquery.ui.datepicker-fa.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
/* Persian (Farsi) Translation for the jQuery UI date picker plugin. */
/* Mohammad Hasani Eghtedar -- m.h.eghtedar@gmail.com */
/* Jalali calendar supported */
jQuery(function($) {
$.datepicker.regional['fa'] = {
calendar: JalaliDate,
closeText: 'بستن',
prevText: 'قبلی',
nextText: 'بعدی',
currentText: 'امروز',
monthNames: [
'فروردين',
'ارديبهشت',
'خرداد',
'تير',
'مرداد',
'شهريور',
'مهر',
'آبان',
'آذر',
'دی',
'بهمن',
'اسفند'
],
monthNamesShort: ['1','2','3','4','5','6','7','8','9','10','11','12'],
dayNames: [
'يکشنبه',
'دوشنبه',
'سه‌شنبه',
'چهارشنبه',
'پنجشنبه',
'جمعه',
'شنبه'
],
dayNamesShort: [
'ی',
'د',
'س',
'چ',
'پ',
'ج',
'ش'
],
dayNamesMin: [
'ی',
'د',
'س',
'چ',
'پ',
'ج',
'ش'
],
weekHeader: 'هف',
dateFormat: 'yy/mm/dd',
firstDay: 6,
isRTL: true,
showMonthAfterYear: false,
yearSuffix: '',
calculateWeek: function(date) {
var checkDate = new JalaliDate(date.getFullYear(), date.getMonth(), date.getDate() + (date.getDay() || 7) - 3);
return Math.floor(Math.round((checkDate.getTime() - new JalaliDate(checkDate.getFullYear(), 0, 1).getTime()) / 86400000) / 7) + 1;
}};
$.datepicker.setDefaults($.datepicker.regional['fa']);
});

function JalaliDate(p0, p1, p2) {
var gregorianDate;
var jalaliDate;

if (!isNaN(parseInt(p0)) && !isNaN(parseInt(p1)) && !isNaN(parseInt(p2))) {
var g = jalali_to_gregorian([parseInt(p0, 10), parseInt(p1, 10), parseInt(p2, 10)]);
setFullDate(new Date(g[0], g[1], g[2]));
} else {
setFullDate(p0);
}

function jalali_to_gregorian(d) {
var adjustDay = 0;
if(d[1]<0){
adjustDay = leap_persian(d[0]-1)? 30: 29;
d[1]++;
}
var gregorian = jd_to_gregorian(persian_to_jd(d[0], d[1] + 1, d[2])-adjustDay);
gregorian[1]--;
return gregorian;
}

function gregorian_to_jalali(d) {
var jalali = jd_to_persian(gregorian_to_jd(d[0], d[1] + 1, d[2]));
jalali[1]--;
return jalali;
}

function setFullDate(date) {
if (date && date.getGregorianDate) date = date.getGregorianDate();
gregorianDate = new Date(date);
gregorianDate.setHours(gregorianDate.getHours() > 12 ? gregorianDate.getHours() + 2 : 0)
if (!gregorianDate || gregorianDate == 'Invalid Date' || isNaN(gregorianDate || !gregorianDate.getDate())) {
gregorianDate = new Date();
}
jalaliDate = gregorian_to_jalali([
gregorianDate.getFullYear(),
gregorianDate.getMonth(),
gregorianDate.getDate()]);
return this;
}

this.getGregorianDate = function() { return gregorianDate; }

this.setFullDate = setFullDate;

this.setMonth = function(e) {
jalaliDate[1] = e;
var g = jalali_to_gregorian(jalaliDate);
gregorianDate = new Date(g[0], g[1], g[2]);
jalaliDate = gregorian_to_jalali([g[0], g[1], g[2]]);
}

this.setDate = function(e) {
jalaliDate[2] = e;
var g = jalali_to_gregorian(jalaliDate);
gregorianDate = new Date(g[0], g[1], g[2]);
jalaliDate = gregorian_to_jalali([g[0], g[1], g[2]]);
};

this.getFullYear = function() { return jalaliDate[0]; };
this.getMonth = function() { return jalaliDate[1]; };
this.getDate = function() { return jalaliDate[2]; };
this.toString = function() { return jalaliDate.join(',').toString(); };
this.getDay = function() { return gregorianDate.getDay(); };
this.getHours = function() { return gregorianDate.getHours(); };
this.getMinutes = function() { return gregorianDate.getMinutes(); };
this.getSeconds = function() { return gregorianDate.getSeconds(); };
this.getTime = function() { return gregorianDate.getTime(); };
this.getTimeZoneOffset = function() { return gregorianDate.getTimeZoneOffset(); };
this.getYear = function() { return jalaliDate[0] % 100; };

this.setHours = function(e) { gregorianDate.setHours(e) };
this.setMinutes = function(e) { gregorianDate.setMinutes(e) };
this.setSeconds = function(e) { gregorianDate.setSeconds(e) };
this.setMilliseconds = function(e) { gregorianDate.setMilliseconds(e) };
}
1 change: 1 addition & 0 deletions demos/datepicker/jquery.ui.datepicker-fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Stéphane Raimbault <stephane.raimbault@gmail.com> */
jQuery(function($){
$.datepicker.regional['fr'] = {
calendar: Date,
closeText: 'Fermer',
prevText: 'Précédent',
nextText: 'Suivant',
Expand Down
1 change: 1 addition & 0 deletions demos/datepicker/jquery.ui.datepicker-he.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* Written by Amir Hardon (ahardon at gmail dot com). */
jQuery(function($){
$.datepicker.regional['he'] = {
calendar: Date,
closeText: 'סגור',
prevText: '&#x3C;הקודם',
nextText: 'הבא&#x3E;',
Expand Down
1 change: 1 addition & 0 deletions demos/datepicker/jquery.ui.datepicker-zh-TW.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* Written by Ressol (ressol@gmail.com). */
jQuery(function($){
$.datepicker.regional['zh-TW'] = {
calendar: Date,
closeText: '關閉',
prevText: '&#x3C;上月',
nextText: '下月&#x3E;',
Expand Down
8 changes: 6 additions & 2 deletions demos/datepicker/localization.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
<script src="../../ui/jquery.ui.widget.js"></script>
<script src="../../ui/jquery.ui.datepicker.js"></script>
<script src="jquery.ui.datepicker-ar.js"></script>
<script src="jquery.ui.datepicker-fa.js"></script>
<script src="jquery.ui.datepicker-fr.js"></script>
<script src="jquery.ui.datepicker-he.js"></script>
<script src="jquery.ui.datepicker-zh-TW.js"></script>
<script src="../../external/astro.js"></script>
<script src="../../external/calendar.js"></script>
<link rel="stylesheet" href="../demos.css">
<script>
$(function() {
$( "#datepicker" ).datepicker( $.datepicker.regional[ "fr" ] );
$( "#datepicker" ).datepicker( $.datepicker.regional[ "fa" ] );
$( "#locale" ).change(function() {
$( "#datepicker" ).datepicker( "option",
$.datepicker.regional[ $( this ).val() ] );
Expand All @@ -27,10 +30,11 @@

<p>Date: <input type="text" id="datepicker"/>&nbsp;
<select id="locale">
<option value="fa" selected="selected">Persian (Farsi) (فارسی)</option>
<option value="ar">Arabic (&#8235;(&#1575;&#1604;&#1593;&#1585;&#1576;&#1610;&#1577;</option>
<option value="zh-TW">Chinese Traditional (&#32321;&#39636;&#20013;&#25991;)</option>
<option value="">English</option>
<option value="fr" selected="selected">French (Fran&ccedil;ais)</option>
<option value="fr">French (Fran&ccedil;ais)</option>
<option value="he">Hebrew (&#8235;(&#1506;&#1489;&#1512;&#1497;&#1514;</option>
</select></p>

Expand Down
Loading