Jump to:

23481 Posts in 18951 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Language fallback mechanism

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: 1153 Views
  • subpixel
    Community Member
    4 Posts

    Language fallback mechanism Link to this post

    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?


  • subpixel
    Community Member
    4 Posts

    Re: Language fallback mechanism Link to this post


    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.

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.