Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set languages for two jquery ui datepickers

I have two jquery ui datepickers in my page and I would like to apply a specific language for each one of them (let says german for one datepicker and italian for the other datepicker)

Now here is the problem: the last language file that is called apply its settings to all the datepickers (in this case, italian is applied in both inputs). I'm using the following code, what should I change to apply a specific language to each of the datepickers? thanks

<script type="text/javascript" src="http://jquery-ui.googlecode.com/svn/trunk/ui/i18n/jquery.ui.datepicker-de.js"></script>

<script type="text/javascript" src="http://jquery-ui.googlecode.com/svn/trunk/ui/i18n/jquery.ui.datepicker-it.js"></script>

$(function(){

    $.datepicker.setDefaults($.datepicker.regional['de']);
    $( "#en" ).datepicker();

    $.datepicker.setDefaults($.datepicker.regional['it']);
    $( "#it" ).datepicker();


    });
like image 466
Vincent Avatar asked Mar 25 '12 12:03

Vincent


1 Answers

This is how you do it: [Read Manual]

$.datepicker.setDefaults($.datepicker.regional['de']); 
                      //  ^ first set a default locale
$("#en").datepicker($.datepicker.regional['en']);  
                 // ^ then different locale for different
$("#it").datepicker($.datepicker.regional['it']);  
like image 156
Starx Avatar answered Oct 01 '22 17:10

Starx