Laravel - DataTable Localization

Viewed 1156

Morning, I'm building a multilanguage site with Laravel. Changing of display language is OK, when user select language (fr or en). But only DataTable options are not translated (search, previous, ...). I can translate it into Datable {language:..} but this method is static. Thks for your help !

1 Answers

I did the same thing for the datatable, You can use laravel lang function and blade syntax for mixing php into script , to do that,You can use laravel lang function for language property for dynamic localization Here is sample for:

$('#example').DataTable( {
    "language": {
        "lengthMenu":"{!!__('dataTable.menu')!!}",
        "zeroRecords": "{!!__('dataTable.zeroRecord')!!}",
        ....

    }
} );

And in resources/lang folder in your laravel project, create correspond php file array for your desired languages

For more information about laravel localization check this

Related