Language translation in jquery date picker

How can I include both the language translation and the changeMonth and changeYear parameters together in the jquery date picker. For this, I used the code below To translate into English

$(this).datepicker($.datepicker.regional['fr']); 

For ChangeYear

 $( this ).datepicker({ changeMonth: true, changeYear: true }); 

I want to run these two in the same datepicker field. Please, help

+6
source share
3 answers

Looking at the source, a regional object is an object with parameters, so this should work:

 $(this).datepicker($.extend({}, $.datepicker.regional['fr'], { changeMonth: true, changeYear: true })); 
+3
source

Here is an easy way (see this JFiddle: http://jsfiddle.net/Kp8Nq/ ). You can change the localization parameter instead of creating a new datepicker:

 $(function () { $("#datepicker").datepicker({ changeMonth: true, changeYear: true }); $("#datepicker").datepicker("option", $.datepicker.regional["fr"]); $("#locale").change(function () { $("#datepicker").datepicker("option", $.datepicker.regional[$(this).val()]); }); }); 
0
source

I personally let the user decide if you have a multinational website:

See: http://jqueryui.com/datepicker/#localization

 <!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <title>jQuery UI Datepicker - Localize calendar</title> <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> <script src="jquery.ui.datepicker-ar.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> <link rel="stylesheet" href="/resources/demos/style.css" /> <script> $(function() { $( "#datepicker" ).datepicker( $.datepicker.regional[ "fr" ] ); $( "#locale" ).change(function() { $( "#datepicker" ).datepicker( "option", $.datepicker.regional[ $( this ).val() ] ); }); }); </script> </head> <body> <p>Date: <input type="text" id="datepicker" />&nbsp; <select id="locale"> <option value="ar">Arabic (‫(العربية</option> <option value="zh-TW">Chinese Traditional (繁體中文)</option> <option value="">English</option> <option value="fr" selected="selected">French (Français)</option> <option value="he">Hebrew (‫(עברית</option> </select></p> </body> </html> 
0
source

Source: https://habr.com/ru/post/952591/


All Articles