Internationalisation

The Editor interface makes use of text to provide information to the end user to indicate what each part of the form does. Much of this text will be provided by your configuration of the form (for example fields.label), but Editor also has a number of built in strings which are used. These default strings are in English, but can easily be translated into another language, or customised to suit your needs.

This ability of Editor's matches DataTables ability to also have its language options configured allowing complete control over the text that your end user sees.

Configuration

The strings Editor uses can be customised using the i18n configuration option. This in turn has a number of sub-objects that are used to group strings that share a common theme:

You may provide as many or as few custom strings as you wish using the i18n option. For example, a full configuration of the strings in French can be provided thus:

let editor = new DataTable.Editor( {
    ajax:  "php/staff.php",
    table: "#myTable",
    i18n: {
        create: {
            button: "Nouveau",
            title:  "Créer nouvelle entrée",
            submit: "Créer"
        },
        edit: {
            button: "Modifier",
            title:  "Modifier entrée",
            submit: "Actualiser"
        },
        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: "Plusieurs valeurs",
            info: "Les éléments sélectionnés contiennent des valeurs différentes pour cette entrée. Pour modifier et mettre tous les éléments pour cette entrée pour la même valeur, cliquez ou appuyez ici, sinon ils vont conserver leurs valeurs individuelles.",
            restore: "Annuler les modifications"
        },
        datetime: {
            previous: 'Précédent',
            next:     'Premier',
            months:   [ 'Janvier', 'Février', 'Mars', 'Avril', 'peut', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre' ],
            weekdays: [ 'Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam' ]
        }
    }
} );

Defaults

It can often be useful to set language strings to default values, particularly if you wish to use different Editor instances in different parts of your site, but you wish to retain use of a common language. Rather than defining the i18n option for every Editor instance you can set defaults using the DataTable.Editor.defaults object.

For example:

$.extend( true, DataTable.Editor.defaults, {
    create: {
        button: "Nouveau",
        title:  "Créer nouvelle entrée",
        submit: "Créer"
    },

    // ...
} );

Note the use of true as the first parameter to $.extend() - this ensures that a deep copy is performed, which is important to ensure that any default values which are not overwritten are not lost.