Giter Site home page Giter Site logo

Comments (4)

krzysiekpiasecki avatar krzysiekpiasecki commented on July 20, 2024

For example in a file src/assets/scripts/datatable/index.js inject french translation object:

import * as $ from 'jquery';
import 'datatables';

export default (function () {
  $('#dataTable').DataTable( {
    language: {
        processing:     "Traitement en cours...",
        search:         "Rechercher :",
        lengthMenu:    "Afficher _MENU_ éléments",
        info:           "Affichage de l'élement _START_ à _END_ sur _TOTAL_ éléments",
        infoEmpty:      "Affichage de l'élement 0 à 0 sur 0 éléments",
        infoFiltered:   "(filtré de _MAX_ éléments au total)",
        infoPostFix:    "",
        loadingRecords: "Chargement en cours...",
        zeroRecords:    "Aucun élément à afficher",
        emptyTable:     "Aucune donnée disponible dans le tableau",
        paginate: {
            first:      "Premier",
            previous:   "Précédent",
            next:       "Suivant",
            last:       "Dernier"
        },
        aria: {
            sortAscending:  ": activer pour trier la colonne par ordre croissant",
            sortDescending: ": activer pour trier la colonne par ordre décroissant"
        }
    }
} );
}());

Read more on i18n of datatables here https://datatables.net/manual/i18n. If you haven't got any other question related to this issue, please close this ticket. Thanks.

from adminator-admin-dashboard.

NikoGrano avatar NikoGrano commented on July 20, 2024

Thank you for telling where put this translation. I have never used node for managing js libraries so still learning.

However I get translation language from PHP. So I have this kind tag tag on HTML header:

<head>
<script>
var contentLang = 'en';
</script>
</head>

So how I can tell datatables what translation must be used?

from adminator-admin-dashboard.

krzysiekpiasecki avatar krzysiekpiasecki commented on July 20, 2024
$('#example').DataTable( {
    language: {
        url: `/localisation/${contentLang}.json`
    }
} );

Just load translation file dynamically from cdn (use cdn URL) or from project resources (need to download). Available translation here https://datatables.net/plug-ins/i18n/.

from adminator-admin-dashboard.

NikoGrano avatar NikoGrano commented on July 20, 2024

@krzysiekpiasecki
Thank you! You made my day! I Would like buy cup of coffee for you, if I could.

Edit: Bought some coffee for you for 20PLN. Have a great day!

from adminator-admin-dashboard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.