Commit 67e6b418 authored by Sven Franck's avatar Sven Franck

fixed translations of popups (outside gadget.dom)

parent bf7d037e
......@@ -65,10 +65,10 @@
</head>
<body>
<span class="ui-hidden-accessible el">&nbsp;</span>
<a data-role="button" class="setIcon" href="" data-rel="popup" data-position-to="origin" data-icon="lang" data-iconpos="notext">Languages</a>
<a data-role="button" class="setIcon popup_trigger" href="" data-rel="popup" data-position-to="origin" data-icon="lang" data-iconpos="notext">Languages</a>
<div data-role="popup" class="all_popups">
<ul data-role="listview" data-inset="true" data-divider-theme="f">
<li data-role="list-divider" class="t" data-i18n="gen.language"></li>
<li data-role="list-divider" class="t" data-i18n="gen.language">Languages</li>
<li data-icon="false"><a class="t change_language" href="?lang=fr-FR" data-i18n-target=".ui-li-text" data-i18n="[title]gen.language_info;[html]gen.lang.fr"><span class="ui-icon ui-fake-icon ui-li-icon ui-icon-lang ui-li-thumb FR">&nbsp;</span><span class="ui-li-text"></span></a></li>
<li data-icon="false"><a class="t change_language" href="?lang=de-DE" data-i18n-target=".ui-li-text" data-i18n="[title]gen.language_info;[html]gen.lang.de"><span class="ui-icon ui-fake-icon ui-li-icon ui-icon-lang ui-li-thumb DE">&nbsp;</span><span class="ui-li-text"></span></a></li>
<li data-icon="false"><a class="t change_language" href="?lang=en-EN" data-i18n-target=".ui-li-text" data-i18n="[title]gen.language_info;[html]gen.lang.en"><span class="ui-icon ui-fake-icon ui-li-icon ui-icon-lang ui-li-thumb EN">&nbsp;</span><span class="ui-li-text"></span></a></li>
......@@ -100,7 +100,7 @@
},
// set language
set_lang = function (language) {
var set_icon, elem, override = false, remote;
var set_icon, elem, override = false, remote, popups, i, link;
switch (language) {
case "de-DE":
......@@ -117,10 +117,6 @@
// trigger create
if (gadget.isEnhanced() === false) {
$(document).trigger("render_enhance", {"gadget": gadget.dom });
// no other way to translate popups, because the popup will be moved to the end of the DOM
remote = gadget.dom.find("a").attr('href');
// doing it differently breaks wrapping elements (collapsibles)
$('.ui-popup-container span.t, .ui-popup-container a.t').i18n();
}
if ( $.fn.fauna.i18n_current_lang !== language ) {
......@@ -129,16 +125,31 @@
// translate all gadgets in the gadget list (dom available)
for (i = 0; i < list.length; i += 1) {
gadget_to_translate = list[i];
if (gadget_to_translate.isEnhanced() === false || override ) {
console.log("found gadget, id="+gadget_to_translate.id);
gadget_to_translate.dom
.find(".t")
.i18n()
.end()
.i18n()
.end()
// in JQM, we also need to update all widgets with "artificial"
// text elements, such as selects
// not nice: there must be a better way to do this!
.find("select").selectmenu("refresh").end();
.find("select")
.selectmenu("refresh")
.end()
.find("a.popup_trigger")
// exclude recursive gadgets
.filter(function(){
return !gadget_to_translate.dom.find("[data-gadget]").find(this).length;
}
)
.each(function(index, element){
remote = element.getAttribute('href').replace('#','');
console.log("got one");
$('#'+remote+'-popup').find('span.t, a.t, li.ui-li-divider').i18n();
}
);
gadget_to_translate.setEnhanced(true);
}
}
......@@ -201,7 +212,7 @@
$(document).ready(function() {
// fallback for old devices which cannot load <style> css
gadget = RenderJs.getSelfGadget()
var gadget = RenderJs.getSelfGadget();
$(this)
.filter(function() { return $(this).jqmData("i18n") !== true; })
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment