2015-11-27 56 views
0

我有一個使用Datatables服務器端的datatable。我已經創建並填充瞭如下所示的表格。現在我需要翻譯取決於語言的數據表,我發現這個例子中,文檔中:數據表翻譯不起作用

$('#example').DataTable({ 
    language: { 
     search: "Search in table:" 
    } 
}); 

或裝載翻譯:

$('#example').DataTable({ 
    language: { 
     url: '/localisation/fr_FR.json' 
    } 
}); 

但他們沒有對我的作品!這是我的代碼:

<table id="example" class="display" cellspacing="0" width="100%"> 
     <thead> 
      <tr> 
       <th>name</th> 
       <th>adress</th> 
      </tr> 
     </thead> 
</table> 

$(document).ready(function() { 
    var oTable = $('#example').DataTable({ 
     "processing": true, 
     "serverSide": true, 
     "ajax": { 
      "url": "server-side-process", 
      }, 

     "columns": [ 
        { "data": "name" }, 
        { "data": "adress" }, 
       ] 
    }); 

}); 
+0

在代碼中有沒有 「語言」 選項。你把它放在哪裏?你能不能顯示'fr_FR.json'文件的內容/格式?控制檯中是否有錯誤? –

+0

我把它放在我的代碼中,它不起作用,控制檯 – AiD

+0

「語言」中有任何錯誤:{ 「search」:「在表中搜索:」 } ...不工作 – AiD

回答

1
var oTable = $('#example').DataTable({ 
    "language": {"url": "//cdn.datatables.net/plug-ins/1.10.15/i18n/Spanish.json"}, 
    "processing": true, 
    "serverSide": true, 
    "ajax": {... 

https://datatables.net/plug-ins/i18n/