admin管理员组文章数量:1300061
How can I include both language translation and changeMonth and changeYear options together in jquery date picker. For that I used the below code For Language translation
$(this).datepicker($.datepicker.regional['fr']);
For ChangeYear
$( this ).datepicker({
changeMonth: true,
changeYear: true
});
I want to run these two in a single datepicker box.Please help
How can I include both language translation and changeMonth and changeYear options together in jquery date picker. For that I used the below code For Language translation
$(this).datepicker($.datepicker.regional['fr']);
For ChangeYear
$( this ).datepicker({
changeMonth: true,
changeYear: true
});
I want to run these two in a single datepicker box.Please help
Share Improve this question asked Aug 27, 2013 at 12:31 Nithin ViswanathanNithin Viswanathan 3,2837 gold badges44 silver badges85 bronze badges3 Answers
Reset to default 4Looking at the source the regional is an object with options so this should work:
$(this).datepicker($.extend({}, $.datepicker.regional['fr'], {
changeMonth: true,
changeYear: true
}));
Here's a simple way (see this JFiddle: http://jsfiddle/Kp8Nq/). You can change the localization option 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()]);
});
});
I personally would let the user decide, if you have a multi-national website:
See: http://jqueryui./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./ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery./jquery-1.9.1.js"></script>
<script src="http://code.jquery./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" />
<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>
本文标签: javascriptLanguage translation in jquery date pickerStack Overflow
版权声明:本文标题:javascript - Language translation in jquery date picker - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741654711a2390690.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论