Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

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

Multilingual and cache


8 Posts   1562 Views


7 January 2009 at 5:09pm Community Member, 17 Posts

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?



8 January 2009 at 2:25pm Administrator, 685 Posts

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


9 January 2009 at 1:09am Community Member, 17 Posts

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?



15 January 2009 at 5:10pm Community Member, 17 Posts

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.



3 February 2009 at 11:42pm Community Member, 126 Posts

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:

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 '' or ''.
presumably not the most clever solution, but it works - i'd be willing to share the code in case anyone's interested (just reply).


4 February 2009 at 3:13am Community Member, 22 Posts

@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


4 February 2009 at 11:11am Community Member, 787 Posts

A similar solution can be found in the comments at:


5 February 2009 at 6:57am Community Member, 126 Posts

@bschmitt: i've just added a recipe in the docs:

@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:

have a nice day