Button text from language file

Button text from language file

ASKempASKemp Posts: 19Questions: 7Answers: 0

I have my DataTable using a language file, all working fine there.

I've added a set of standard buttons via
new $.fn.dataTable.Buttons
(table,
{
name: "buttons",
buttons: ["copy", "csv", "excel", "pdf", "print"]
}
);

and append them to a container. All fine there as well.

However, I can't work out how I can localise the text of those buttons, ideally from reference to the language file?
many thanks...

Answers

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

    Hi @ASKemp ,

    This example here shows how to internationalise your Buttons strings.

    Cheers,

    Colin

  • ASKempASKemp Posts: 19Questions: 7Answers: 0
    edited October 2019

    Many thanks, saw that one, how do you do it with the buttons defined outside of the main datatable, I have the language file in the main part.

    Also, what would be the button references?

  • LapointeLapointe Posts: 430Questions: 81Answers: 4

    you can define default buttons text as :

        $.extend( true, $.fn.dataTable.Editor.defaults, {
            i18n: {
                upload: {button: "Modifier", title:  "Modifier la fiche", submit: "Enregistrer"},
                create: {button: "Nouveau", title:  "Création d'une nouvelle fiche", submit: "Créer"},
                edit: {button: "Modifier", title:  "Modifier entrée",submit: "Enregistrer"},
                remove: {button: "Supprimer", title:  "Supprimer", submit: "Supprimer",
                    confirm: {_: "Etes-vous sûr de vouloir supprimer %d lignes?", 1: "Etes-vous sûr de vouloir supprimer 1 ligne?"}
                },
                error: {system: "Une erreur s’est produite, contacter l’administrateur système"},
                multi: {title: "Valeurs multiples", restore: "Annuler les modifications",
                    info: "Les enregistrements sélectionnés contiennent des valeurs différentes pour cette donnée. Pour définir une valeur identique pour tous les enregistrements sélectionnés, cliquez ici.",
                    noMulti: "Cette entrée peut être modifiée individuellement, mais ne fait pas partie d'un groupe."
                },
                datetime: {previous: 'Précédent', next:     'Suivant', months:   [ 'Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre' ],
                    weekdays: [ 'Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam' ], unknown:  '?',
                }
            }
        });
    

    so each time you will use a button, it will use the correct caption
    The button reference does not change yet...

This discussion has been closed.