bootstrap table默认是英文语言包,我们可以通过以下设置进行本地化中文设置,比如分页、加载进度进行中文提示。
<script src="bootstrap-table-en-US.js"></script>
<script src="bootstrap-table-zh-CN.js"></script>
<table data-toggle="table" data-locale="en-US">
</table>
$('#table').bootstrapTable({
locale: 'en-US'
})
不加载语言包,通过自定义的方式设置,代码如下
$('#table').bootstrapTable({
//自定义分页字符串显示为中文
formatShowingRows:function(pageFrom, pageTo, totalRows)
{
return "第"+pageFrom+"-"+pageTo+"行,总共"+totalRows+"";
},
//自定义分页字符串显示为中文
formatRecordsPerPage:function(pageNumber)
{
return pageNumber+'行每页';
}
});
$('#table').bootstrapTable({
//加载数据时提示
formatLoadingMessage:function()
{
return "数据加载中...";
},
//每页显示
formatRecordsPerPage:function(pageNumber)
{
return pageNumber+'行每页';
},
//页码
formatShowingRows:function(pageFrom, pageTo, totalRows)
{
return "第"+pageFrom+"-"+pageTo+"行,总共"+totalRows+"";
},
formatSRPaginationPreText :function(){
return '上一页';
},
formatSRPaginationPageText:function(page){
return '跳转至'+page;
},
formatSRPaginationNextText:function(){
return '下一页';
},
formatDetailPagination:function(totalRows)
{
return "总计:"+totalRows;
}
,
formatSearch:function()
{
return "搜索";
}
,
formatClearSearch:function()
{
return "清除搜索";
}
,
formatNoMatches:function()
{
return "未查询到相关记录";
} ,
formatPaginationSwitch:function()
{
return "隐藏显示分页";
}
,
formatPaginationSwitchDown:function()
{
return "显示分页";
},
formatPaginationSwitchUp:function()
{
return "隐藏分页";
} ,
formatRefresh:function()
{
return "刷新";
} ,
formatToggle:function()
{
return "展开";
} ,
formatToggleOn:function()
{
return "显示卡片视图";
} ,
formatToggleOff :function()
{
return "隐藏卡片视图";
},
formatColumns:function(){
return "列视图";
}
,
formatColumnsToggleAll:function()
{
return 'Toggle all';
}
,
formatFullscreen:function()
{
return '全屏';
} ,
formatAllRows function()
{
return '全部';
}
});