Internationalisation/localisation of lengthMenu

Internationalisation/localisation of lengthMenu

greenflashgreenflash Posts: 58Questions: 5Answers: 0

I want to use the -1 option in lengthMenu as in

$('#example').dataTable( {
  "lengthMenu": [ [10, 25, 50, -1], [10, 25, 50, "All"] ]
} );

but I can't seem to find a way of localising the "All" text. Is there a way in DataTables?

Replies

  • colincolin Posts: 15,146Questions: 1Answers: 2,586

    No, as it's your own string, you would need to deal with that in your code.

    Colin

  • greenflashgreenflash Posts: 58Questions: 5Answers: 0

    Thanks. Are there any thoughts about making this a DataTables string in future? I would have thought that everybody would want "All" or their local language equivalent for the -1 option, and so making this a DataTables string would make life much easier for applications using DataTables that have to support many languages.

  • allanallan Posts: 61,743Questions: 1Answers: 10,111 Site admin

    I think Colin's point is that you'd just do:

    $('#example').dataTable( {
      "lengthMenu": [ [10, 25, 50, -1], [10, 25, 50, "Toute"] ]
    } );
    

    But are you meaning that you want to use it inside the language object and possibly load it via Ajax? If so, honestly, that's not something I'd thought of before. I'm not sure why as it seems fairly obvious now. I've created an issue for that on our internal tracker (DD-1335), but it might be v2 before that gets addressed.

    Allan

  • greenflashgreenflash Posts: 58Questions: 5Answers: 0
    edited January 2020

    Thanks. Yes, I'd like a language.all option and maybe

    $('#example').dataTable( {
      "lengthMenu": [ 10, 25, 50, -1 ]
    } );
    

    should default to

    $('#example').dataTable( {
      "lengthMenu": [ [10, 25, 50, -1], [10, 25, 50, language.all] ]
    } );
    

    and then it could be overridden by, for example,

    $('#example').dataTable( {
      "lengthMenu": [ [10, 25, 50, -1], ["ten", "twenty-five", "fifty", "the lot"] ]
    } );
    

    Maybe there are better ways of doing it. But certainly a language.all option please.

    Thanks.

This discussion has been closed.