jqwidgets 国际化- 中文 jqxGrid 中文语言包 gridlocalization

来源:互联网 发布:邻里中国网php面试题 编辑:程序博客网 时间:2024/06/08 20:23

最近在整合使用jqwidgets ,这个是一个非常强大的js库,应有尽有
在使用jqxgrid的时候,发现英文的,API中并没有提供中文语言
官方网址:https://www.jqwidgets.com/

这里写图片描述

使用过jGrid 的同学们,突然好不习惯,有没有;
jGrid 很强大,而且比较简单易用;
那么为什么要用jqwidgets ,因为 jqwidgets 真的是太强大了
好了,这里不是比较的;
如果之前使用的jGrid 切换到jqwidgets ,好像不太一样,那没关系,我们自己封装一个转换器,不就可以了?这个我们稍后再讨论。

言归正传,下面自己做了一个中文的语言包:
给他起个名字吧: jqwidget.locale-cn.js

;(function($){    $.jqx._jqxGrid = $.jqx._jqxGrid || {};    $.extend($.jqx._jqxGrid.prototype,{        gridlocalization:{            "/" : "/",            ":" : ":",            firstDay : 0,            days : {                names : [ "Sunday", "Monday",                        "Tuesday", "Wednesday",                        "Thursday", "Friday",                        "Saturday" ],                namesAbbr : [ "Sun", "Mon", "Tue",                        "Wed", "Thu", "Fri", "Sat" ],                namesShort : [ "Su", "Mo", "Tu", "We",                        "Th", "Fr", "Sa" ]            },            months : {                names : [ "January", "February",                        "March", "April", "May",                        "June", "July", "August",                        "September", "October",                        "November", "December", "" ],                namesAbbr : [ "Jan", "Feb", "Mar",                        "Apr", "May", "Jun", "Jul",                        "Aug", "Sep", "Oct", "Nov",                        "Dec", "" ]            },            AM : [ "AM", "am", "AM" ],            PM : [ "PM", "pm", "PM" ],            eras : [ {                name : "A.D.",                start : null,                offset : 0            } ],            twoDigitYearMax : 2029,            patterns : {                d : "M/d/yyyy",                D : "dddd, MMMM dd, yyyy",                t : "h:mm tt",                T : "h:mm:ss tt",                f : "dddd, MMMM dd, yyyy h:mm tt",                F : "dddd, MMMM dd, yyyy h:mm:ss tt",                M : "MMMM dd",                Y : "yyyy MMMM",                S : "yyyy\u0027-\u0027MM\u0027-\u0027dd\u0027T\u0027HH\u0027:\u0027mm\u0027:\u0027ss",                ISO : "yyyy-MM-dd hh:mm:ss",                ISO2 : "yyyy-MM-dd HH:mm:ss",                d1 : "dd.MM.yyyy",                d2 : "dd-MM-yyyy",                d3 : "dd-MMMM-yyyy",                d4 : "dd-MM-yy",                d5 : "H:mm",                d6 : "HH:mm",                d7 : "HH:mm tt",                d8 : "dd/MMMM/yyyy",                d9 : "MMMM-dd",                d10 : "MM-dd",                d11 : "MM-dd-yyyy"            },            percentsymbol : "%",            currencysymbol : "$",            currencysymbolposition : "before",            decimalseparator : ".",            thousandsseparator : ",",            pagergotopagestring : "跳往:",            pagershowrowsstring : "每页显示:",            pagerrangestring : " 共 ",            pagerpreviousbuttonstring : "上一页",            pagernextbuttonstring : "下一页",            pagerfirstbuttonstring : "第一页",            pagerlastbuttonstring : "最后一页",            groupsheaderstring : "Drag a column and drop it here to group by that column",            sortascendingstring : "升序排序",            sortdescendingstring : "降序排序",            sortremovestring : "删除排序",            groupbystring : "Group By this column",            groupremovestring : "Remove from groups",            filterclearstring : "Clear",            filterstring : "Filter",            filtershowrowstring : "Show rows where:",            filtershowrowdatestring : "Show rows where date:",            filterorconditionstring : "Or",            filterandconditionstring : "And",            filterselectallstring : "(Select All)",            filterchoosestring : "Please Choose:",            filterstringcomparisonoperators : [                    "empty", "not empty", "contains",                    "contains(match case)",                    "does not contain",                    "does not contain(match case)",                    "starts with",                    "starts with(match case)",                    "ends with",                    "ends with(match case)", "equal",                    "equal(match case)", "null",                    "not null" ],            filternumericcomparisonoperators : [                    "equal", "not equal", "less than",                    "less than or equal",                    "greater than",                    "greater than or equal", "null",                    "not null" ],            filterdatecomparisonoperators : [ "equal",                    "not equal", "less than",                    "less than or equal",                    "greater than",                    "greater than or equal", "null",                    "not null" ],            filterbooleancomparisonoperators : [                    "equal", "not equal" ],            validationstring : "Entered value is not valid",            emptydatastring : "No data to display",            filterselectstring : "Select Filter",            loadtext : "Loading...",            clearstring : "Clear",            todaystring : "Today",            addrowstring : "Add",            udpaterowstring : "Update",            deleterowstring : "Delete",            resetrowstring : "Reset",            everpresentrowplaceholder : "Enter "        },        localizestrings:function(){        }    });})(jqxBaseFramework);

以上就是jqwidget.locale-cn.js的代码了
这里我只添加了 jqxGrid 部分中文语言,有其他需要可以给我留言

看看结果吧

这里写图片描述

js引入部分:

<script type="text/javascript" src="jqwidgets/jqx-all.js"></script> <script type="text/javascript" src="jqwidgets/jqwidget.locale-cn.js"></script>

题外:

使用自己封装了jqxGrid 与就Grid 转换器
让它们在用法上做到一致,换一个前端框架不再折腾
这里写图片描述

原创粉丝点击