Jump to:

23376 Posts in 18214 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » Multilingual and cache

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1540 Views
  • stinkytofu
    Avatar
    Community Member
    17 Posts

    Multilingual and cache Link to this post

    Is there anyway to avoid using HTTP::set_cache_age(0) in the config.php file when switching between multi-lingual pages where translated pages share the same URL as the original page? I don't want to disable the cache on the CMS because of the performance hit.

    If not, what are the alternatives? Should I append a ?lang=en at the end of each href link in the HTML code to specify the language and prevent the page from being loaded from the cache whenever user switches languages? What is the best way to avoid using set_cache_age(0) in config.php?

    Thanks.

  • Sam
    Avatar
    Administrator
    679 Posts

    Re: Multilingual and cache Link to this post

    Putting ?lang=en explicitly on the end of the URL is probably the best way.

  • stinkytofu
    Avatar
    Community Member
    17 Posts

    Re: Multilingual and cache Link to this post

    Cheers Sam.

    My question then is how can I automatically put ?lang=en at the end of the URLs created using the WYSIWYG editor in the CMS?

    Thanks!

  • stinkytofu
    Avatar
    Community Member
    17 Posts

    Re: Multilingual and cache Link to this post

    Okay, I found a simple solution to this problem using JQuery.

    I just use something like $('a') in JQuery to get an array of all the links in the page, and then use Javascript to append ?lang=en to the end of each URL in the code.

    Phil

  • schellmax
    Avatar
    Community Member
    126 Posts

    Re: Multilingual and cache Link to this post

    there are many comments in the forum on the 'translatable' being overhauled in the 2.4 release - for now, it's still kind of a mess - UI troubles and the url problem you mentioned kept me away from using it.

    nevertheless, the cms itself is great work, so i stayed with it and found a way around based on this (2 years old) thread:
    http://silverstripe.org/archive/show/543

    in short, it enables me to have separate fields for the translated content, which will be shown when you have a language prefix in your url like 'mysite.com/en/about' or 'mysite.com/de/about'.
    presumably not the most clever solution, but it works - i'd be willing to share the code in case anyone's interested (just reply).

  • bschmitt
    Avatar
    Community Member
    22 Posts

    Re: Multilingual and cache Link to this post

    @schellmax: I would be appreciate if you can share this implementation!

    I totally agree with your comments to the unfinished translation module.

    Many thanks, Bjoern

  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Re: Multilingual and cache Link to this post

    A similar solution can be found in the comments at:
    http://doc.silverstripe.com/doku.php?id=multilingualcontent

  • schellmax
    Avatar
    Community Member
    126 Posts

    Re: Multilingual and cache Link to this post

    hi
    @bschmitt: i've just added a recipe in the docs: http://doc.silverstripe.com/doku.php?id=recipes:multilingual_content

    @Fuzz10: thanks for the hint, in fact my solution is pretty similar to yours (re-invention of the wheel...) but not exactly the same (regarding the more generalized approach of translatable fields and the url building) - i'd love to hear your comments on this.

    i created a thread for this topic, please feel free to post there: http://www.silverstripe.org/general-questions/show/253576

    have a nice day

    1540 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.