1. 程式人生 > >【bootstrap框架】各種官方非官方的datepicker預設顯示中文以及指定頁面顯示中文的方法

【bootstrap框架】各種官方非官方的datepicker預設顯示中文以及指定頁面顯示中文的方法

1、

在datapicker的js檔案中將一下內容進行改變,紅色為增加內容。

var dates=

$.fn.datetimepicker.dates={en:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],daysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sun"],daysMin:["Su","Mo","Tu","We","Th","Fr","Sa","Su"],months:["January","February"

,"March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]},cn:{days:["週日","週一","週二","週三","週四","週五","週六","週日"],daysShort:["","","","","","","",""],daysMin:["","","","","
"
,"","",""],months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],monthsShort:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],}};

2、

在datapicker的js檔案中搜索language

凡是帶有language啥啥啥en的,都將en更改成cn就好。

3、如果有特殊需求,比如說某個頁面就想用英文顯示,可以在該頁面新增以下內容。

$('.date-picker').datepicker({
                language: 'cn',//對應相應的語言
            })

4、知識都是活的,也許你用的不是官方的datetimepicker,但是你就照著它原有的en:{各種變數}修改就行,舉一個不太現實但是很好懂的例子,你用的可能是en:{dayyyys:["Sunday]等等等等},那你新增中文的時候,就把本要貼上的程式碼days更改成dayyyys,只要和他原來的保持一致就ok了。

你的js是否格式化這都無所謂,在百度上搜索js格式化就有線上網站可用你做出想要的修改。

隨意提供一個格式化地址

http://tool.lanrentuku.com/jsformat/