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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

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

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

Language fallback mechanism

Go to End

2 Posts   1686 Views


Community Member, 4 Posts

24 August 2010 at 7:10pm

Hi, I'm using SS 2.4.1 with multilingual site (Translatable extension).
I would like to know if there's any client language recognition? If so, how is it working?
I've set default language to different one than is my locale, and I've received page in default language (so it's not working, but I might set something wrong).
What I'm looking for is a mechanism that would try to set language to client locale language and if there isn't such translation it should fallback to default one.
Also what do you think about setting lang to $_SERVER["HTTP_ACCEPT_LANGUAGE"]. Is it safe?



Community Member, 4 Posts

27 August 2010 at 10:22pm


I placed this code in page_controller init function.

if (substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2)!='de') {
} else {

However, it did it's job only partial. I got navigation from appropriate translation, but haome page and error pages came from default locale.

Than I moved this code to _config.php. And it solved all my problems.
However it seems like an ugly hack. Anyone has a better idea?

Note: I know it's a really simple condition, but I have a bilingual site and I'm not looking for anything sophisticated.