Search…

X3 Photo Gallery Support Forums

Search…
 
User avatar
Haider of Sweden
Experienced
Topic Author
Posts: 54
Joined: 09 Jan 2013, 05:02

Translate the word Images used in Amount

17 Aug 2017, 04:03

Hi!

How can I translate the word "images" when I activate "amount"?
Thanks!
Kind regards,
Haider
www.haider.se
 
User avatar
mjau-mjau
X3 Wizard
Posts: 14452
Joined: 30 Sep 2006, 03:37

Re: Translate the word Images used in Amount

17 Aug 2017, 04:39

Haider of Sweden wrote:How can I translate the word "images" when I activate "amount"?
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.
 
User avatar
Haider of Sweden
Experienced
Topic Author
Posts: 54
Joined: 09 Jan 2013, 05:02

Re: Translate the word Images used in Amount

17 Aug 2017, 08:56

If you please have a look at www.haider.se/portfolio/ you will see the word "images" that I was referring to.
Previously, you helped me with another translation matter: https://forum.photo.gallery/viewtopic.p ... 305#p41754
Maybe this can be solved the same way?
Kind regards,
Haider
www.haider.se
 
User avatar
mjau-mjau
X3 Wizard
Posts: 14452
Joined: 30 Sep 2006, 03:37

Re: Translate the word Images used in Amount

17 Aug 2017, 10:50

Try this:
Code
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');
        }
    }
}
 
User avatar
mjau-mjau
X3 Wizard
Posts: 14452
Joined: 30 Sep 2006, 03:37

Re: Translate the word Images used in Amount

17 Aug 2017, 11:14

Also, you probably want to execute the function like below so that it also executes on AJAX page-navigation from the menu. If you just run hideOneImage(), that function will only execute on the first page you load.
Code
function x3_load_page(){
  hideOneImage();
}
 
User avatar
Haider of Sweden
Experienced
Topic Author
Posts: 54
Joined: 09 Jan 2013, 05:02

Re: Translate the word Images used in Amount

18 Aug 2017, 03:29

Thank you Karl

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.
Code
else {
            elements[i].innerHTML = str.replace('image', 'REPLACEMENT_TEXT');
        }
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.


Just out of curiosity, I noticed that beside the recent code you gave me
Code
x3_load_page()
you have also used this one before
Code
x3_load()
What is the difference between the two?
Kind regards,
Haider
www.haider.se
 
User avatar
mjau-mjau
X3 Wizard
Posts: 14452
Joined: 30 Sep 2006, 03:37

Re: Translate the word Images used in Amount

18 Aug 2017, 04:07

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.
Code
else {
  elements[i].innerHTML = str.replace('image', 'REPLACEMENT_TEXT');
}
Sorry, there was an undefined var "str", which I edited out after. Use this:
Code
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();
}
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.
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.

This is a hack, and it's unproductive to spend resources writing a javascript search and replace script to edit random elements on the page. Why not just DISABLE "amount" from the carousel menu?
Haider of Sweden wrote:Just out of curiosity, I noticed that beside the recent code you gave me
Code
x3_load_page()
you have also used this one before
Code
x3_load()
What is the difference between the two?
This is explained in the "help" section for custom javascript:
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:
Code
function x3_load(){
  console.log('Runs ONCE after x3 is loaded and jQuery is available.');
}
x3_load_page()
This function executes every time an X3 page loads through Ajax. The function therefore triggers for each page load. Example:
Code
function x3_load_page(){
  console.log('Runs after EVERY X3 AJAX page load');
}
 
User avatar
Haider of Sweden
Experienced
Topic Author
Posts: 54
Joined: 09 Jan 2013, 05:02

Re: Translate the word Images used in Amount

18 Aug 2017, 05:35

I'll be better in reading the documentation, but thank you for taking your time helping me out :)
Why not just DISABLE "amount" from the carousel menu?
This is an option of course. But I felt like I liked showing the amount of images, and accepted for long "0 images" even though it meant 0 images in that particular folder, without a clue that there could be sub-folders with images.
When I discovered the javascript way, I thought I could as well solve this in the same go.
Kind regards,
Haider
www.haider.se