The buttons in the modal windows are not translatable.

Comments

mstef’s picture

Good catch

mstef’s picture

As far as I can tell, this can't be done. Mess with it. Let me know if you can get it to work..

Michsk’s picture

i've been trying before i posted this but i will have another look at it.

Michsk’s picture

no idea how to fix this... i tried placing the language in a var but that does not do it either. This is a kind of a flaw...

mstef’s picture

Try submitted an issue with jQuery UI.

mstef’s picture

Status: Active » Postponed
doubouil’s picture

I found a way of translating Buttons of jQuery UI. It's an override of the createButtons function of jQuery UI and an object containing what we want ( translated title, and class for me). It's the same idea behind native implementation of jQueryProps (not very well documented).

My object :

jQuery.keyProps = {
        login: {
            title: "Se connecter", // insert the translated title
            css_class: "dialog-login"
        },
        password: {
            title: "Oubli du mot de passe",
            css_class: "dialog-password"
        },
        passwordsubmit: {
            title: "Envoyer",
            css_class: "dialog-login"
        }
    };

The overriden function :

 $.ui.dialog.prototype._createButtons = function (buttons) {
            var self = this,
                hasButtons = false,
                uiDialogButtonPane = $('<div></div>').addClass('ui-dialog-buttonpane ' + 'ui-widget-content ' + 'ui-helper-clearfix');

            // if we already have a button pane, remove it
            this.uiDialog.find('.ui-dialog-buttonpane').remove();

            (typeof buttons == 'object' && buttons !== null && $.each(buttons, function () {
                return !(hasButtons = true);
            }));
            if (hasButtons) {
                $.each(buttons, function (name, fn) {
                    $('<button type="button"></button>')



.addClass('ui-state-default ' + 'ui-corner-all ' + jQuery.keyProps[name] ? jQuery.keyProps[name]["css_class"] : "")

.text(jQuery.keyProps[name] ? jQuery.keyProps[name]["title"] : name).click(function () {




                        fn.apply(self.element[0], arguments);
                    }).hover(

                    function () {
                        $(this).addClass('ui-state-hover');
                    }, function () {
                        $(this).removeClass('ui-state-hover');
                    }).focus(function () {
                        $(this).addClass('ui-state-focus');
                    }).blur(function () {
                        $(this).removeClass('ui-state-focus');
                    }).appendTo(uiDialogButtonPane);
                });
                uiDialogButtonPane.appendTo(this.uiDialog);
            }
        }


    }

This way, the key of the buttons object is langage neutral, and you can translate the title. My idea was to pass a button object with a text and an another object for attributes inside, similar to the PHP drupal_attributes but in jQuery.

I use jQuery UI 1.7.3.

brianV’s picture

Version: 6.x-2.x-dev » 6.x-3.x-dev
Status: Postponed » Closed (duplicate)

Marking as duplicate of #991572: Homebox buttons not translated. The other issue is newer, but utilizes a proper method with the Drupal.t() localization function.