Easyui date is a method for loading Chinese characters when an English easyui-lang-zh_CN.js is not loaded,

Source: Internet
Author: User
Tags valid email address

Easyui date is a method for loading Chinese characters when an English easyui-lang-zh_CN.js is not loaded,

We sometimes in the easyui operation was originally loaded easyui-lang-zh_CN.js Chinese file package, but still appeared in English. In this way, we should not blame this framework for its poor usage. In fact, if we take a closer look at this Chinese package, we will find that many of them have re-modified the parameters of the definition language. Suppose we use jquery to initialize the Loading Method $ (function () {// here is our custom operation method }); after executing the content in this method, we found that our Chinese language was not loaded. below is the datetimebox date control js code I wrote:

       $(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>

When the form is loaded, it also appears in English. After a long time, I had to remember how to define this Chinese package.

Open the Chinese package file and see what the file contains:

If ($. fn. pagination) {$. fn. pagination. defaults. beforePageText = 'dide'; $. fn. pagination. defaults. afterPageText = 'total {pages} page'; $. fn. pagination. defaults. displayMsg = 'show {from} to {to}, total {total} record ';} if ($. fn. datagrid) {$. fn. datagrid. defaults. loadMsg = 'processing... please wait... ';} 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 input item is mandatory '; $. fn. validatebox. defaults. rules. email. message = 'enter a valid email address'; $. fn. validatebox. defaults. rules. url. message = 'enter a valid URL address'; $. fn. validatebox. Defaults. rules. length. message = 'length of the input content must be between {0} and {1} '; $. fn. validatebox. defaults. rules. remote. message = 'Please correct this field'; $. fn. validatebox. defaults. rules. mphone. message = 'enter the 11-digit mobile phone number. '; $. fn. validatebox. defaults. rules. phone. message = 'Number format: 010-12345678 ';} if ($. fn. numberbox) {$. fn. numberbox. defaults. missingMessage = 'this input item is mandatory ';} if ($. fn. combobox) {$. fn. combobox. defaults. missingMessage = 'this input item is mandatory ';} if ($. fn. comb Otree) {$. fn. combotree. defaults. missingMessage = 'this input item is mandatory ';} if ($. fn. combogrid) {$. fn. combogrid. defaults. missingMessage = 'this input item is mandatory ';} if ($. fn. calendar) {$. fn. calendar. defaults. weeks = ['day', 'yi', '2', '3', '4', '5', '6']; $. fn. calendar. defaults. months = ['August 11', 'August 11', 'August 11', 'August 11', 'August 11', 'August 11', 'August 30', 'August 30 ', 'August 11', 'August 11', 'August 11'];} if ($. fn. datebox) {$. fn. datebox. defaults. currentText = 'today '; $. fn. datebox. defaults. closeText = 'Close'; $. fn. datebox. defaults. okText = 'OK'; $. fn. datebox. defaults. missingMessage = 'this input item is mandatory '; $. 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, S-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 });}

The above shows that there is nothing in this js file. It is very simple, that is, some custom parameters and set them to Chinese. Next, we can put the referenced control language setting function in the initialization method.

$ (Function () {if ($. fn. calendar) {$. fn. calendar. defaults. weeks = ['day', 'yi', '2', '3', '4', '5', '6']; $. fn. calendar. defaults. months = ['August 11', 'August 11', 'August 11', 'August 11', 'August 11', 'August 11', 'August 30', 'August 30 ', 'August 11', 'August 11', 'August 11'];} if ($. fn. datebox) {$. fn. datebox. defaults. currentText = 'today '; $. fn. datebox. defaults. closeText = 'close'; $. fn. datebox. defaults. okText = 'OK'; $. fn. datebox. defaults. missingMessage = 'This input item is mandatory Item '; $. 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});} function adddaytimes () {$ ("# ExpireTime "). datetimebox ("setValue", seprateDateString ($ ("# ReleaseTime "). datetimebox ("getValue");} $ ("# ReleaseTime "). datetimebox ({onChange: adddaytimes });});

Click "View" to view the form, which is changed from English to Chinese. If you encounter such a problem, you can help. There are also better ways to share with you.

 




Related Article

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.