Translation: how to set french language in my calling script?

Translation: how to set french language in my calling script?

Track9890Track9890 Posts: 7Questions: 2Answers: 0
edited November 2023 in Free community support

My script for calling Datatables is different from the one specified in official Datatables documentation. I am talking about tyhis one :

<script type="text/javascript">
new DataTable('#example', {
    language: {
        url: 'https://cdn.datatables.net/plug-ins/1.13.7/i18n/fr-FR.json'
    }
});
</script>

I add to come with this one since it was not working.

<script type="text/javascript">
    $(document).ready(function() {
        $('#indexprix').DataTable({
                "paging":   false,
                "ordering": true,
                "info":     false
            });
    });
</script>

How can I bring langage file calling into my calling script to make it french translated?

Answers

  • kthorngrenkthorngren Posts: 21,336Questions: 26Answers: 4,953

    Combine all the configuration options into one Datatables initialization, like this:

            $('#indexprix').DataTable({
                    "paging":   false,
                    "ordering": true,
                    "info":     false,
                    language: {
                        url: 'https://cdn.datatables.net/plug-ins/1.13.7/i18n/fr-FR.json'
                    }
                });
    

    Kevin

  • Track9890Track9890 Posts: 7Questions: 2Answers: 0

    Like this?

    <script type="text/javascript">
    $('#indexprix').DataTable({
            "paging":   false,
            "ordering": true,
            "info":     false,
            language: {
                url: 'https://cdn.datatables.net/plug-ins/1.13.7/i18n/fr-FR.json'
            }
        });
    </script>
    
  • kthorngrenkthorngren Posts: 21,336Questions: 26Answers: 4,953

    Yes you might want to use document.ready() like you had before. Basically just add t

            language: {
                url: 'https://cdn.datatables.net/plug-ins/1.13.7/i18n/fr-FR.json'
            }
    

    to the Datatables init code you already have.

    Kevin

  • allanallan Posts: 63,504Questions: 1Answers: 10,471 Site admin

    Also to note new DataTable(selector, options) is the same as $(selector).DataTable(options).

    I'm updating the documentation to focus on new DataTable(...) at the moment - but there is a lot of it!

    The two can be used interchangably.

    Allan

  • Track9890Track9890 Posts: 7Questions: 2Answers: 0

    This does work. Databable is not loading.

    <script type="text/javascript">
        $('#indexprix').DataTable({
                "paging":   false,
                "ordering": true,
                "info":     false,
                language: {
                    url: 'https://cdn.datatables.net/plug-ins/1.13.7/i18n/fr-FR.json'
                }
            });
    </script>
    
  • allanallan Posts: 63,504Questions: 1Answers: 10,471 Site admin

    Seems to run okay if I copy and paste it into an example: https://live.datatables.net/tekixufe/1/edit .

    Perhaps you can link to a page that is showing the issue so we can help you to debug it.

    Allan

Sign In or Register to comment.