问题描述
我已经对所维护的Web应用程序的UI进行了几处修改.其中包括从NuGet获取JS库,并将它们与以前的版本对齐.
I have performed several modifications to the UI of a web application I am maintaining. These include fetching JS libraries from NuGet and aligning them to a more recent version than the previous.
运行jQuery 1.8.2和jQuery UI 1.8.24的旧版本(由Firebug和自定义,缩小,重新美化了)显示给您)运行完全本地化的DatePicker
,包括格式dd/MM/yyyy
,这是MVC页面连接到文本框中的数据格式.
The old version, running jQuery 1.8.2 and jQuery UI 1.8.24 (customized, minified, re-beautified by Firebug and shown to you) runs a perfectly localized DatePicker
, including format dd/MM/yyyy
which is the format of data wired into the text boxes by MVC pages.
现在,我已经获取了jQuery 1.11.2和jQuery UI 1.11.2,并假设一切都会按预期进行.
Now I have fetched jQuery 1.11.2 and jQuery UI 1.11.2, presuming that everything will continue to work as expected.
不.
DatePicker仍按以下方式初始化:
The DatePicker are still initialized as follows:
<script type="text/javascript">
$(function() {
$.datepicker.setDefaults($.extend({ showMonthAfterYear: false }, $.datepicker.regional['']));
$(".datePicker").datepicker($.datepicker.regional['it']);
$('.datePicker').datepicker('option', 'changeMonth', true);
$('.datePicker').datepicker('option', 'changeYear', true);
$("#locale").change(function() {
$('.datePicker').datepicker('option', $.extend({ showMonthAfterYear: false },
$.datepicker.regional[$(this).val()]));
});
});
</script>
文本框是
<input type="text" class="datePicker" id="date_begin" name="pDateBegin" value="<%=Some.Data %>" readonly="readonly"/>
<input type="text" class="datePicker" id="date_end" name="pDateEnd" value="<%=Some.Data %>" readonly="readonly"/>
简而言之,旧的应用程序显示一个本地化的日历并接受dd/MM/yyyy
日期.新的重构应用程序显然不接受日期24/02/2015
作为有效日期,而文本框为空白.该版本显示了英语本地化的日历,而JS代码要求it
地区.在旧应用程序的Firebug控制台上,我可以正确看到$.datepicker.regional['it']
的值,而在新应用程序中则为空.
Briefly, the old application shows a well-localized calendar and accepts dd/MM/yyyy
dates. The new refactored application doesn't obviously accept dates as 24/02/2015
as valid dates, leaving the textbox blank. And that version shows an English localized calendar while the JS code requires it
regional. From Firebug console on the old application I can see the value of $.datepicker.regional['it']
correctly, and it's empty in the new application.
我想查找,以自己解决问题,在代码中定义了IT区域,但是未找到Chiudi
(其消息显示为"Close"(关闭)消息)任何事物.看来这语言是来自神秘世界的.
I wanted to track down, to solve the problem myself, where in the code the IT regional is defined, but searching for Chiudi
(it message for "Close") doesn't find anything. It looks like the language comes from the mistery.
旧的应用程序包含以下文件(按Firebug的顺序):
The old application includes the following files (in Firebug's order):
- jquery.form.js
- jquery-1.8.2-min.js
- jquery-ui-1.8.24.custom.min.js(链接粘贴,魔术单词Chiudi没有结果)
- superfish.js
- 自定义应用程序的JS脚本(包含在新应用程序中,无论如何都不会覆盖日期选择器)
- MicrosoftAjax.js
- MicrosoftMVC.js
- jquery.tablesorter.js
- jquery.tablesorter.pager.js
在ASPX代码中甚至都找不到对datepicker区域的覆盖,在我正在检查的页面中我还没有更改它.
An override of datepicker's regional is not even found in the ASPX code, which I haven't changed yet in the page I'm examining.
如何在 jQuery UI 的标准NuGet发行版中添加语言?
How to add languages to the standard NuGet distribution of jQuery UI?
推荐答案
您可以包含以下代码:
<script type="text/javascript"
src="http://jqueryui.com/ui/i18n/jquery.ui.datepicker-fr.js">
</script>
http://jqueryui.com/datepicker/#localization -查看此演示和;您可以从此处下载语言文件: https://github.com/jquery /jquery-ui/tree/master/ui/i18n
http://jqueryui.com/datepicker/#localization - Check it out this demo & you can download language file from here: https://github.com/jquery/jquery-ui/tree/master/ui/i18n
这篇关于本地化在jQuery UI datePicker中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!