Hi!
How can I translate the word "images" when I activate "amount"?
Thanks!
X3 Photo Gallery Support Forums
These translations are not yet a feature of X3, but I can perhaps provide a temporary fix. Do you have a link to the page? I am not quite sure if you are referring to "images" in the main menu or in a page layout.Haider of Sweden wrote:How can I translate the word "images" when I activate "amount"?
function hideOneImage(){
var elements = document.getElementsByClassName("amount")
for (var i = 0; i < elements.length; i++){
if(elements[i].innerHTML == "1 image"){
elements[i].style.display = "none";
} else {
elements[i].innerHTML = str.replace('image', 'REPLACEMENT_TEXT');
}
}
}function x3_load_page(){
hideOneImage();
}Sorry, there was an undefined var "str", which I edited out after. Use this:Haider of Sweden wrote:Even for a non-coder like me, the code looks like it should work, but yet the following part breaks the whole thing - the page turns white.Codeelse { elements[i].innerHTML = str.replace('image', 'REPLACEMENT_TEXT'); }
function hideOneImage(){
var elements = document.getElementsByClassName("amount");
for (var i = 0; i < elements.length; i++){
if(elements[i].innerHTML == "1 image"){
elements[i].style.display = "none";
} else {
elements[i].innerHTML = elements[i].innerHTML.replace('image', 'REPLACEMENT_TEXT');
}
}
}
function x3_load_page(){
hideOneImage();
}Yes, the menu is rendered AFTER by javascript, like much of the elements in X3 and many modern HTML5 websites. That is why the source will differ in Chrome inspector than the raw page source code.Haider of Sweden wrote:Also, I noticed the script does not have an effect on menus. When I look into the source code, I cannot see the menu elements, but in Chrome Inspect, I can. Seems like the menu is rendered afterwards.
This is explained in the "help" section for custom javascript:Haider of Sweden wrote:Just out of curiosity, I noticed that beside the recent code you gave meyou have also used this one beforeCodex3_load_page()What is the difference between the two?Codex3_load()
x3_load()
This function executes once the X3 application is fully loaded and ready. This also means jQuery has been loaded and is available to be used. Example:x3_load_page()Codefunction x3_load(){ console.log('Runs ONCE after x3 is loaded and jQuery is available.'); }
This function executes every time an X3 page loads through Ajax. The function therefore triggers for each page load. Example:Codefunction x3_load_page(){ console.log('Runs after EVERY X3 AJAX page load'); }