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
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" });
精彩评论