Internationalisation problem

Internationalisation problem

abrachetabrachet Posts: 8Questions: 0Answers: 0
edited May 2012 in DataTables 1.9
Hi there,

I have trouble translating my datatables' texts. Here is what I did.

First I added the script reference in my main page :
[code][/code]

In this page I also got a reference to my script library :
[code][/code]

In this library, I did this function :
[code]
$(function () {

// defines default configuration for DataTables
$.extend($.fn.dataTable.defaults, {
bAutoWidth: false,
bFilter: false,
bLengthChange: false,
bProcessing: true,
bServerSide: true,
iDisplayLength: 20,
iDeferLoading: 0,
sPaginationType: 'full_numbers',
sUrl: '/assets/js/resources/jquery.dataTables.fr-FR.txt'
});
[/code]

In each page that contains a datatable I got something like :
[code]
$(function () {

// target DataTables for members in a group
var MembersInAGroup = $('#MembersInAGroup').dataTable({
aoColumns: [
{ mDataProp: 'avatar', ... },
{ mDataProp: 'lastName', ... },
{ mDataProp: 'firstName', ... }
],
fnServerParams: function (aoData) {
tools.dtSearchOnField(aoData, '#GroupID', 'GroupID');
},
iDisplayLength: 5,
sAjaxSource: '@Url.Action("SearchMembers", "DataTables")'
});
[/code]

I don't understand why the localized strings are not applied. Any help would be greatly appreciated :)

Thank u so much,
AB

Replies

  • allanallan Posts: 63,397Questions: 1Answers: 10,451 Site admin
    sUrl is not a top level option - its in the oLanguage object. Try this:

    [code]
    // defines default configuration for DataTables
    $.extend(true, $.fn.dataTable.defaults, {
    bAutoWidth: false,
    bFilter: false,
    bLengthChange: false,
    bProcessing: true,
    bServerSide: true,
    iDisplayLength: 20,
    iDeferLoading: 0,
    sPaginationType: 'full_numbers',
    "oLanguage": {
    sUrl: '/assets/js/resources/jquery.dataTables.fr-FR.txt'
    }
    });
    [/code]

    Allan
  • abrachetabrachet Posts: 8Questions: 0Answers: 0
    edited May 2012
    Hi Allan,

    Thank u for reply. It changes a little bit but doesn't work anymore.

    Now the text are translated but the datatable is not bound and by default, the "processing..." is always displayed.

    I must precise that I got this code in each page where a datatable is included :
    [code]
    $(function () {
    // target DataTables for members in a group
    var MembersInAGroup = $('#MembersInAGroup').dataTable({
    aoColumns: [
    { mDataProp: 'avatar', ... },
    { mDataProp: 'lastName', ... },
    { mDataProp: 'firstName', ... },
    ],
    fnServerParams: function (aoData) {
    tools.dtSearchOnField(aoData, '#GroupID', 'GroupID');
    },
    iDisplayLength: 5,
    sAjaxSource: '@Url.Action("SearchMembers", "DataTables")'
    });
    [/code]

    Note that if I add oLanguage there, it works... But I'd like a common place for the entire application.
This discussion has been closed.