gpt4 book ai didi

javascript - DataTables - 翻译与选择扩展相关的文本

转载 作者:数据小太阳 更新时间:2023-10-29 05:15:00 26 4
gpt4 key购买 nike

我正在使用带有 Select 扩展的 jQuery DataTables v1.10.9。

选中一行或多行时,底部会出现文字,例如,“选择了 2 行”,请参见下面的屏幕截图:

语言文件:

{
"sEmptyTable": "No data available in table",
"sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
"sInfoEmpty": "Showing 0 to 0 of 0 entries",
"sInfoFiltered": "(filtered from _MAX_ total entries)",
"sInfoPostFix": "",
"sInfoThousands": ",",
"sLengthMenu": "Show _MENU_ entries",
"sLoadingRecords": "Loading...",
"sProcessing": "Processing...",
"sSearch": "Search:",
"sZeroRecords": "No matching records found",
"oPaginate": {
"sFirst": "First",
"sLast": "Last",
"sNext": "Next",
"sPrevious": "Previous"
},
"select": {
"rows": {
"_": "You have selected %d rows",
"0": "Click a row to select",
"1": "1 row selected"
}
}
}

表初始化:

dataTableY = $('#tableID').DataTable({
serverSide: true,
ajax: {
url: myProp.base_url + 'directory/class/method'
},
processing: true,
scrollY: 420,
paging: true,
info: true,
searchable: true,
select: {
style: 'os'
},
pagingType: 'full_numbers',
language: {
url: myProp.base_url + '/DataTables/lang/language.json'
}
});

我该如何翻译这段文字?

最佳答案

使用下面的代码:

$(document).ready(function() {
$('#example').DataTable( {
select: true,
language: {
select: {
rows: {
_: "You have selected %d rows",
0: "Click a row to select it",
1: "Only 1 row selected"
}
}
}
} );
} );

参见 Select - Internationalization example用于演示。

如果您想在语言文件中使用它,请使用以下格式:

{
"sEmptyTable": "No data available in table",
"sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
"sInfoEmpty": "Showing 0 to 0 of 0 entries",
"sInfoFiltered": "(filtered from _MAX_ total entries)",
"sInfoPostFix": "",
"sInfoThousands": ",",
"sLengthMenu": "Show _MENU_ entries",
"sLoadingRecords": "Loading...",
"sProcessing": "Processing...",
"sSearch": "Search:",
"sZeroRecords": "No matching records found",
"oPaginate": {
"sFirst": "First",
"sLast": "Last",
"sNext": "Next",
"sPrevious": "Previous"
},
"select": {
"rows": {
"_": "You have selected %d rows",
"0": "Click a row to select",
"1": "1 row selected"
}
}
}

参见 this jsFiddle用于代码和演示。

关于javascript - DataTables - 翻译与选择扩展相关的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33133428/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com