How to force internationalization i18 to reload the page when changing language?

Hello all,
well, the translation module is too smart for me: it seems like when selecting another language from the menu, it manages to update the page internationalized content without actually reloading it. That's obviously great. It's just that I integrated a nice photo flexslider component which requires to be initialised and started with a few lines of javascript (using window.onload), and when I select another language, the slider disappears.
If I navigate to another page and back, then the slider is up again, but I would like it to remain in place when changing language.
I thought of a way to force a full reload of the page when selecting another language, but I am open to any suggestion ;)
Many thanks!

Comments

  • acrylian Administrator

    well, the translation module is too smart for me: it seems like when selecting another language from the menu, it manages to update the page internationalized content without actually reloading it.

    No, translation is using PHP gettext, therefore server side and the language selector does reload the page to switch.

    Sorry, can't help with that script but perhaps browser caches are playing tricks on you. If the slider disappears you should review the browser console to see if there are any JS errors occurring.

  • Thank you very much for your quick answer!
    Good to know that the translator actually reloads the page.
    I checked the console/server logs and found no errors though. And the onload event on the page is not fired... It is fired if I navigate to another page and come back to the page I was on when selecting the other language. Then the js component gets initialized on loading.
    I tried different browsers and clearing the caches... no joy.
    But thanks for the information. I know at least where it doesn't come from ;)

  • acrylian Administrator
    edited November 30

    This actually sounds like a browser cache issue to me. I recently had a lot of fun with the browser cache of Safari for example. It is sometimes so persistent that even force clearing several times does not change anything. It is really annoying. Firefox and Chrome don't show this annoying behaviour.

  • Could be, browser caches can be quite tricky. But I tried Safari, Firefox and Chrome, clearing all cache and stored data before selecting another language, and onload event is not triggered. It's enough to go to a gallery page and click "home" back to index, and then it is triggered and everything works fine... wouldn't make much sense for a browser cache, would it?

  • But I just found a bxslider plugin in Zenphoto. I guess I will give it a try instead of trying to integrate a third party slider ;)

  • acrylian Administrator

    I did encounter browsers behave differently if you reload or really reload the page freshliy (like hitting enter in the address bar). Especially js and css are quite persistently cached.

    Have you tried disabling the cache? In FIrefox at least that is easily possible.

  • acrylian Administrator

    You can also use the slideshow2 plugin, both include slider scripts.

    Still the reason might be how your slider script does things that interferes somehow…

  • Tried with cache disabled, no difference. I'll try slideshow2.
    Would you have any link to an example about how to include it in a page after enabling it in the admin frontend?

  • acrylian Administrator
    edited November 30

    The slideshow itself is currently built into every official theme so you don't need to do much. Otherrwise take a look here:
    https://docs.zenphoto.org/function-printSlideShow.html

    (Same info to be found within the plugin file itself).

  • Thanks!

Sign In or Register to comment.