Easyui Date Load Chinese method without loading easyui-lang-zh_cn.js in English

Source: Internet
Author: User

We sometimes in the operation of the Easyui is loaded with the Easyui-lang-zh_cn.js Chinese file package, but still appeared in English. So that we can not complain about this framework is so bad, in fact, we look at this Chinese package will find that many are re-modified the definition of the language parameters. If we initialize the Load method with jquery $ (function () {//Here is our custom method of operation}); This method inside of the implementation of things after the discovery is not loaded our Chinese below is I wrote the Datetimebox date control JS code:

       $ (function () {           function adddaytimes () {                    $ ("#ExpireTime"). Datetimebox ("SetValue", Sepratedatestring ($ ("# Releasetime "). Datetimebox (" GetValue "));            }            $ ("#ReleaseTime"). Datetimebox ({                onchange:adddaytimes            });    });

Even if I import this Chinese package on the page: <script src= ". /easyui/locale/easyui-lang-zh_cn.js "type=" Text/javascript "></script>

In the form of loading the same will appear in English, tangled for a long time finally have to remember to see how the Chinese package is defined.

Let's open up and look at this Chinese package file, what is the content:

if ($.fn.pagination) {$.fn.pagination.defaults.beforepagetext = ' first '; $.fn.pagination.defaults.afterpagetext = ' Total { Pages} page '; $.fn.pagination.defaults.displaymsg = ' Show {from} to {to}, with {total} record ';} if ($.fn.datagrid) {$.fn.datagrid.defaults.loadmsg = ' is being processed, please wait a moment ... ‘;} if ($.fn.treegrid && $.fn.datagrid) {$.fn.treegrid.defaults.loadmsg = $.fn.datagrid.defaults.loadmsg;} if ($.messager) {$.messager.defaults.ok = ' OK '; $.messager.defaults.cancel = ' Cancel ';} if ($.fn.validatebox) {$.fn.validatebox.defaults.missingmessage = ' This entry is a must-lose '; $. Fn.validatebox.defaults.rules.email.message = ' Please enter a valid e-mail address '; $.fn.validatebox.defaults.rules.url.message = ' Please enter a valid URL address '; $.fn.validatebox.defaults.rules.length.message = ' The input length must be between {0} and {1} '; $. Fn.validatebox.defaults.rules.remote.message = ' Please fix this field '; $.fn.validatebox.defaults.rules.mphone.message = ' Please enter a 11-digit phone number. '; $.fn.validatebox.defaults.rules.phone.message = ' number format 010-12345678 ';} if ($.fn.numberbox) {$.fn.numberbox.defaults.missingmessage = ' This entry is a must-lose ';} if ($.fn.combobox) {$.FN.COmbobox.defaults.missingMessage = ' This entry is a must-lose ';} if ($.fn.combotree) {$.fn.combotree.defaults.missingmessage = ' This entry is a must-lose ';} if ($.fn.combogrid) {$.fn.combogrid.defaults.missingmessage = ' This entry is a must-lose ';} if ($.fn.calendar) {$.fn.calendar.defaults.weeks = [' Day ', ' one ', ' two ', ' three ', ' four ', ' five ', ' six '];$.fn.calendar.defaults.months = [' January ', ' February ', ' March ', ' April ', ' May ', ' June ', ' July ', ' August ', ' September ', ' October ', ' November ', ' December ';} if ($.fn.datebox) {$.fn.datebox.defaults.currenttext = ' today '; $.fn.datebox.defaults.closetext = ' close '; $. Fn.datebox.defaults.okText = ' OK '; $.fn.datebox.defaults.missingmessage = ' The entry is a must-lose '; $. Fn.datebox.defaults.formatter = function (date) {var y = date.getfullyear (); var m = Date.getmonth () +1;var d = date.getdate ( ); return y+ '-' + (m<10? (') 0 ' +m): m) + '-' + (d<10? (') 0 ' +d):d);}; $.fn.datebox.defaults.parser = function (s) {if (!s) return new Date (), var ss = S.split ('-'); var y = parseint (ss[0],10); var m = parseint (ss[1],10), var d = parseint (ss[2],10), if (!isnan (y) &&!isnan (m) &&!isnan (d)) {return new Date (y,m-1,d);} else {REturn new Date ();}};} if ($.fn.datetimebox && $.fn.datebox) {$.extend ($.fn.datetimebox.defaults,{currenttext: $. Fn.datebox.defaults.currenttext,closetext: $.fn.datebox.defaults.closetext,oktext: $.fn.datebox.defaults.okText, Missingmessage: $.fn.datebox.defaults.missingmessage});}

  above can see that there is nothing in this JS file, very simple, is a few custom parameters and set to Chinese. Next, we can put the referenced control language setting function into the initialization method.

       $ (function () {if ($.fn.calendar) {$.fn.calendar.defaults.weeks = [' Day ', ' one ', ' two ', ' three ',                ' Four ', ' five ', ' six '];            $.fn.calendar.defaults.months = [' January ', ' February ', ' March ', ' April ', ' May ', ' June ', ' July ', ' August ', ' September ', ' October ', ' November ', ' December '];                } if ($.fn.datebox) {$.fn.datebox.defaults.currenttext = ' today ';                $.fn.datebox.defaults.closetext = ' off ';                $.fn.datebox.defaults.oktext = ' OK ';                $.fn.datebox.defaults.missingmessage = ' The input is a must-lose ';                    $.fn.datebox.defaults.formatter = function (date) {var y = date.getfullyear ();                    var m = date.getmonth () + 1;                    var d = date.getdate (); Return y + '-' + (M < 10?) (' 0 ' + m): m) + '-' + (D < 10?)                (' 0 ' + D): D);                };                    $.fn.datebox.defaults.parser = function (s) {if (!s) return new Date (); var ss = S.spliT ('-');                    var y = parseint (ss[0], 10);                    var m = parseint (ss[1], 10);                    var d = parseint (ss[2], 10);                    if (!isnan (y) &&!isnan (m) &&!isnan (d)) {return new Date (Y, m-1, D);                    } else {return new Date ();            }                };                    } if ($.fn.datetimebox && $.fn.datebox) {$.extend ($.fn.datetimebox.defaults, {                    Currenttext: $.fn.datebox.defaults.currenttext, Closetext: $.fn.datebox.defaults.closetext, Oktext: $.fn.datebox.defaults.oktext, Missingmessage: $.FN.DATEBOX.DEFAULTS.MISSINGM            Essage}); } function Adddaytimes () {$ ("#ExpireTime"). Datetimebox ("SetValue", Sepratedatestring ($ ("#Re            Leasetime "). Datetimebox (" GetValue ")); } $ ("#ReleaSetime "). Datetimebox ({onchange:adddaytimes}); });

Click on the form to view it from the original English into Chinese. Students who wish to meet such problems can help you. There is a better way for everyone to share.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.