Internationalisation - "Confirm" delete message not working?

Internationalisation - "Confirm" delete message not working?

Dirk FincleyDirk Fincley Posts: 38Questions: 3Answers: 0
edited March 2016 in Free community support

I cannot get the Spanish "confirm" test to appear. I have the code below in place and everything works except the confirmation text for the confirm delete which still shows in English ("Are you sure that you want to delete the following row(s)?") not Spanish. I cannot see why this would not work.

Has the tag name been changed from "confirm" to something else? If so what? Or can anone see a syntax error which would stop it from working?
...

$(document).ready(function() {

var editor = new $.fn.dataTable.Editor( {
    ajax: 'php/table.country.php',
    table: '#country',  

    i18n: {
    "create": {
        "button": "Neuvo",
        "title":  "Crear nueva entrada",
        "submit": "Crear"
    },
    "edit": {
        "button": "Modificar",
        "title":  "Modificar un ingreso",
        "submit": "refresca"
    },
    "remove": {
        "button":   "Eliminar",
        "title":    "Eliminar",
        "submit":   "Eliminar",
        "confirm": {
            _: "Está seguro de que desea eliminar % d líneas ?",
            1: "Está seguro de que quiere borrar la línea 1"
        }
    },
    "error": {
        "system": "Se ha producido un error , póngase en contacto con el administrador del sistema"
    },
    "multi": {
        "title": "Varios valores",
        "info": "Los elementos seleccionados contienen valores diferentes para esta entrada . Para editar y mover todos los elementos para esta entrada por el mismo valor , haga clic o presione aquí , de lo contrario, conservarán sus valores individuales",
        "restore": "Cancelar cambios"
    },
    "datetime": {
        "previous":         'Anterior',
        "next":             'Primero',
        "months":        [ 'Enero' , 'Febrero', 'Julio' , 'Marzo' ,  'Abril', 'Mayo' , 'Junio' , ' Julio ' , 'Agosto', ' Septiembre ' ,  'Octubre' , ' Diciembre'],
        "weekdays":     [ 'Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado' ]
    }
},

...

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin

    Hi,

    I've just tried the above locally and it actually appears to work okay.

    Can you give me a link the page so I can take a look into it please?

    Thanks,
    Allan

  • Dirk FincleyDirk Fincley Posts: 38Questions: 3Answers: 0

    Thanks Alan.

    I found the problem myself when I looked closely the java script file uses a "formMessage" line which is "hard coded" in English. I will need to replace this with te appropriate i18n remove button confirm variable. Any idea what this is called?

    ...

        columns: [
            {
                "data": "region.id",
            },
            {
                "data": "region.region_name"
            },
            {
                "data": "country.country_name"
            }
        ],
        select: true,
        lengthChange: false,
        buttons: [
            { extend: 'create', editor: editor },
            { extend: 'edit',   editor: editor },
            {
                extend: "remove",
                editor: editor,
                formMessage: function ( e, dt ) {
                    var rows = dt.rows( e.modifier() ).data();
                    return 'Are you sure you want to delete the following '+
                        'row(s)? <ul><li>'+rows.join('</li><li>')+'</li></ul>';
                }
            }   
        ]
    } );
    

    } );

    }(jQuery));

    ...

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin

    Could you tell me where in the code you are seeing the issue? As I mentioned, I tried your code above exactly as it was and it appeared to work without issue.

    You can also see the i18n customisation of the delete message in this example.

    Allan

  • Dirk FincleyDirk Fincley Posts: 38Questions: 3Answers: 0
    edited March 2016

    Allan. It is my fault. This issue is my use of the "formMessage" text which is "overriding" the standard confirmation text. So I get "Are you sure you want to delete the following" and the number of rows instead of the Spanish Delete button confirmation text "Está seguro de que quiere borrar la línea 1".

    If I use :

    ...
    buttons: [
    { extend: 'create', editor: editor },
    { extend: 'edit', editor: editor },
    { extend: 'remove', editor: editor }
    ...

    I get the correct Spanish confirmation text.

    My second question was can I reference the i18n: delete confirmation text directly in my formMessage - so I would pull in the standard confirmation text in whatever language I was using instead of "hard coding" it in the formMessage?

  • Dirk FincleyDirk Fincley Posts: 38Questions: 3Answers: 0
    edited March 2016

    So instead of returning 'Are you sure you want to delete the following '+ 'row(s)? I wanted to use the variable name of the variable containing the delete confirmation message.

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin

    I'm not sure I quite understand I'm afraid. If you can successfully set a string as a confirmation message, why can't you set a variable as that value (and that variable would contain the required string)?

    Allan

  • Dirk FincleyDirk Fincley Posts: 38Questions: 3Answers: 0
    edited March 2016

    Sorry Allan. The issue is that I do not know the name of the variable which contains the default text. I do want to specify a variable name rather than the text string which I am assigning in the formMesssage. I want the default value (whatever language is chosen) rather than the English string.

    Is it i18n.remove.confirm._?

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin
    Answer ✓

    Oh I see - i18n.remove.confirm is the option. The _ is part of the pluralisation options as detailed on that reference page.

    Allan

  • Dirk FincleyDirk Fincley Posts: 38Questions: 3Answers: 0

    Great. Missed that. Should be easy enough to use that in a formMessage of my own.

This discussion has been closed.