Jump to:

23379 Posts in 18298 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » Trouble with Translatable and _t()?

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: 739 Views
  • omarkohl
    Avatar
    Community Member
    30 Posts

    Trouble with Translatable and _t()? Link to this post

    If you have a site in several languages and you want to save yourself a lot of trouble and a few hours of headache I recommend you put this in the init() function of your Page_Controller.

    i18n::set_locale(Translatable::get_current_locale());
    setlocale(LC_ALL, i18n::get_locale());

    Otherwise string translated using _t() or php functions like strftime won't work as you want them to.

    I can see the point SilverStripe developers tried to make when separating i18n from Translatable and in theory it makes sense. In practice though its really annoying because _t() is used so much in SS modules.

  • dacar
    Avatar
    Community Member
    168 Posts

    Re: Trouble with Translatable and _t()? Link to this post

    Omarkohl, you are a the best. I have played with this for hours without success. Just insert the code and everything was fine. This shut be put to the documentation!

  • ordinarywebguy
    Avatar
    Community Member
    13 Posts

    Re: Trouble with Translatable and _t()? Link to this post

    Try putting it up this like:

    setlocale(LC_TIME, i18n::get_locale() . '.utf8');

    It should do the trick.

    739 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.