Cannot change the language

Cannot change the language

GruntGrunt Posts: 5Questions: 3Answers: 0

Hi!

I am using DataTables-1.10.13 and trying to translate the menu of my DataTables but it does not work.
I tried this:

    <script type="text/javascript" language="javascript">
        $(document).ready(function(){
            $('#table_id').DataTable({
                serverSide: true,
                language: {
                    url: "{{ asset('vendor/DataTables-1.10.13/plug-ins/lang/French.json') }}"
                },
                ajax: {
                    url: "{{ asset('vendor/DataTables-1.10.13/perso/server_side/scripts/listSent.php') }}",
                    dataType: "jsonp"                   
                }
            });
        });
    </script>

I also replaced:

                language: {
                    url: "{{ asset('vendor/DataTables-1.10.13/plug-ins/lang/French.json') }}"
                }

by

                language: {
                    url: "{{ asset('vendor/DataTables-1.10.13/plug-ins/lang/French.lang') }}"
                }

But in both changes, the data appear correctly but the names from menu remain in english.

I also tried:

    <script type="text/javascript" language="javascript">
        $(document).ready(function(){
            $('#table_id').DataTable({
                serverSide: true,
                    "language": {
                        "sProcessing": "Traitement en cours ...",
                        "sLengthMenu": "Afficher _MENU_ lignes",
                        "sZeroRecords": "Aucun résultat trouvé",
                        "sEmptyTable": "Aucune donnée disponible",
                        "sInfo": "Lignes _START_ à _END_ sur _TOTAL_",
                        "sInfoEmpty": "Aucune ligne affichée",
                        "sInfoFiltered": "(Filtrer un maximum de_MAX_)",
                        "sInfoPostFix": "",
                        "sSearch": "Chercher:",
                        "sUrl": "",
                        "sInfoThousands": ",",
                        "sLoadingRecords": "Chargement...",
                        "oPaginate": {
                          "sFirst": "Premier", "sLast": "Dernier", "sNext": "Suivant", "sPrevious": "Précédent"
                        },
                        "oAria": {
                          "sSortAscending": ": Trier par ordre croissant", "sSortDescending": ": Trier par ordre décroissant"
                        }
                    }
                ajax: {
                    url: "{{ asset('vendor/DataTables-1.10.13/perso/server_side/scripts/listSent.php') }}",
                    dataType: "jsonp"                   
                }
            });
        });
    </script>

In this case, my data do not appear...
Any idea?

Answers

  • GruntGrunt Posts: 5Questions: 3Answers: 0

    So it works with the second solution:

    <script type="text/javascript" language="javascript">
        $(document).ready(function(){
            $('#table_id').DataTable({
                serverSide: true,
                    "language": {
                        "sProcessing": "Traitement en cours ...",
                        "sLengthMenu": "Afficher _MENU_ lignes",
                        "sZeroRecords": "Aucun résultat trouvé",
                        "sEmptyTable": "Aucune donnée disponible",
                        "sInfo": "Lignes _START_ à _END_ sur _TOTAL_",
                        "sInfoEmpty": "Aucune ligne affichée",
                        "sInfoFiltered": "(Filtrer un maximum de_MAX_)",
                        "sInfoPostFix": "",
                        "sSearch": "Chercher:",
                        "sUrl": "",
                        "sInfoThousands": ",",
                        "sLoadingRecords": "Chargement...",
                        "oPaginate": {
                          "sFirst": "Premier", "sLast": "Dernier", "sNext": "Suivant", "sPrevious": "Précédent"
                        },
                        "oAria": {
                          "sSortAscending": ": Trier par ordre croissant", "sSortDescending": ": Trier par ordre décroissant"
                        }
                    },
                ajax: {
                    url: "{{ asset('vendor/DataTables-1.10.13/perso/server_side/scripts/listSent.php') }}",
                    dataType: "jsonp"                  
                }
            });
        });
    </script>
    

    I forgot a comma but why the first solution using the url does not work? I used the file from the GitHub repository of DataTables.

  • allanallan Posts: 63,350Questions: 1Answers: 10,443 Site admin

    I used the file from the GitHub repository of DataTables.

    This one? It isn't valid JSON. Use the files from the CDN instead. They are valid JSON.

    The github files contain meta data.

    Allan

This discussion has been closed.