How to configure the jQuery UI Datepicker to use a localized calendar?
I'm wondering if this is possible and if yes, how would I go about doing it? I'm trying to make the widget use a Jalali(Persian) Calender.
jQuery UI Datepicker localization
In general, to add localization to jQuery UI Datepicker you need to include a specific localization file immediately after including the Datepicker's script. For example, to set a French localization, you'd do this:
[...include jQuery and jQuery UI...]
<script type="text/javascript" src="jquery.ui.datepicker-fr.js"></script>
The localization files are included as part of the the standard jQuery UI download, in a separate directory ( development-bundle/ui/i18n
). For more on this, see the Datepicker API documentation (under "Localization").
Current status: Farsi in, Jalali out
Currently, jQuery UI download package doesn't seem to include a Jalali localization file. For now, there seems to be only a regular (Georgian) calendar translated into Farsi ( jquery.ui.datepicker-fr.js
).
Solution 1 - custom localization file
If you prefer to stick with jQuery UI's datepicker, you can create a custom localization file, based on the format of existing localization files. If you're familiar with the calendar in question, it shouldn't be difficult.
Solution 2 - use a different plugin
Consider using the jQuery Calendars plugin instead. It already includes most common world calendars in several languages and formats, so generating a Jalali or any other foreign calendar for that matter is done by the flick of a setting.
Not so much a solution, albeit not a complete one, but I've just found this nice implementation, the article is in Persian, but the author implements the jQuery UI datepicker with both the Persian and Arabic Calenders.
EDIT 9/6/2013:
Another contribution on Github, I like this implementation better as it saves me from having to read form collection values and perform dodgy string manipulations to convert the date.
Might be too late, but since I stumbled on it, here is a demo someone has been kind enough to put up. All credits to unknown author http://jquery-ui.googlecode.com/svn/tags/1.6rc5/demos/datepicker/localization.html
链接地址: http://www.djcxy.com/p/67950.html