为什么我的jquery UI datepicker不会默认为英文 [英] why is my jquery UI datepicker not defaulting to english

查看:117
本文介绍了为什么我的jquery UI datepicker不会默认为英文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我基本上将代码从这里复制,但是当我测试我的网站时,我看到了这一点: p>

alt text http:// img148。 imagehack.us/img148/8167/datepicker.png



任何想法为什么我没有得到英文日历

解决方案

从jQuery UI文档,它基于您的计算机的区域设置,如c0mrade在评论中所说,但您可以覆盖:



本地化


Datepicker支持本地化其内容以满足不同的语言和日期格式。每个定位都包含在其自己的文件中,其语言代码附加到名称,例如法语的jquery.ui.datepicker-fr.js。这些文件在主日期代码之后加载。他们将其设置添加到可用的本地化集合中,并自动将其应用于所有实例的默认值。



$ .datepicker.regional属性包含一组本地化,语言代码,指为默认(英文)。每个条目是具有以下属性的对象:closeText,prevText,nextText,currentText,monthNames,monthNamesShort,dayNames,dayNamesShort,dayNamesMin,weekHeader,dateFormat,firstDay,isRTL,showMonthAfterYear和yearSuffix。



您可以通过以下方式恢复默认本地化:




  $。datepicker。 setDefaults($。datepicker.regional ['']); 




然后可以覆盖特定区域设置的单个日期戳: p>



  $(selector).datepicker($。datepicker.regional ['fr']); 


i basically copied the code from here but when i tested my site i saw this:

alt text http://img148.imageshack.us/img148/8167/datepicker.png

any idea why i am not getting an english calendar

解决方案

From the jQuery UI docs, it's based on your computer's locale as c0mrade said in comments, but you can override:

Localization

Datepicker provides support for localizing its content to cater for different languages and date formats. Each localization is contained within its own file with the language code appended to the name, e.g. jquery.ui.datepicker-fr.js for French. These files are loaded after the main datepicker code. They add their settings to the set of available localizations and automatically apply them as defaults for all instances.

The $.datepicker.regional attribute holds an array of localizations, indexed by language code, with '' referring to the default (English). Each entry is an object with the following attributes: closeText, prevText, nextText, currentText, monthNames, monthNamesShort, dayNames, dayNamesShort, dayNamesMin, weekHeader, dateFormat, firstDay, isRTL, showMonthAfterYear, and yearSuffix.

You can restore the default localizations with:

$.datepicker.setDefaults($.datepicker.regional['']);

And can then override an individual datepicker for a specific locale:

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

这篇关于为什么我的jquery UI datepicker不会默认为英文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆