DataTable and internationalization


#1

I’d like to change the language of the embedded objects (search, paging,…): I’ve tried to use the language object described at https://datatables.net/manual/i18n but I get only error messages … Does anybody know a way out? Thanks


#2

How did you try to use the object?
What error(s) are you getting?

Providing a sample of the .nsx file maybe helpful👍🏻


#3

You might also ask on the DataTables support page. This is a big and complicated library - the best support for it is probably there.


#4

Hi! Basically I’m using the DataTable.nsx sample project where I call with a button the initlang function (analyzing the uncaught error I think that the reason is that you cannot rebuild the existing DataTable object, DataTable1 ).

JavaScript

function initlang() {
   $("#DataTable1").DataTable( {
      "language": {
           "search": "Filter"         
 }
} );  

}

End JavaScript


#5

From the DataTables forum I tried a solution … I attach the link to an example for the “search” embedded label (solution kindly suggested by Tester2017)

where YOUR_LABEL_TEXT is the translation of the search label and YOUR_TABLE_NAME is the name of the datatable in your code.

Unfortunately if you use it, the search box does not work any more


#6

Thanks for posting what you have found so far!


#7

From the DataTables forum I finally got a working solution (suggestion by rduncecb)

function changeSearchLabel(table, newLabel) {
    var input = $("#"+ table + "_filter > label > input").detach();
    $("#" + table + "_filter > label").html(newLabel).append(input);
}

where newLabel is the translation of the search label and table is the name of the datatable in your code


#8

Tip: Surround your code by triple tics ``` and it will be formatted nicely!

(I did for you)