gerpaick
gerpaick

Reputation: 799

jQuery.localize translate jquery.dialog messages

I'm using a jQuery Dialog to display some information and jquery-localize to translate the user interface.

To localise I use https://github.com/coderifous/jquery-localize

I have this code in my <head>, but I don't know hot to localize the buttons...

$('#dialog').dialog({
 autoOpen: false,
 width: 600,
 modal: true,       
 buttons: {
  "Yes, I would like to have this one": function() {
    doSomeStuff();
       $( this ).dialog( "close" );
 },
 "No, I prefer to don't..": function() {
    $( this ).dialog( "close" );
                        }
                    }
                });

Can I use same resource that jQuery.localize uses? And if yes, how can I do that? If not, how can I localize JavaScript strings and values?

Thanks a lot

Upvotes: 1

Views: 1245

Answers (1)

jk.
jk.

Reputation: 14435

jquery.localize uses a rel attribute. If you already have jquery.localize set up, you should be able to add the rel when you open the dialog:

$('#dialog').dialog("open");
$("button.ui-button span:contains('Yes, i would like')").attr("rel","localize[your_value]");
$("button.ui-button span:contains('No, i prefer')").attr("rel","localize[your_value]");

Then call localize (taken from the docs - yours may be different):

$("rel*=localize").localize("application", { language: "es" });

Upvotes: 1

Related Questions