22399 Posts in 6752 Topics by 2748 members
General questions about getting started with SilverStripe that don't fit in any of the categories above.
|Go to End|
12 December 2010 at 3:20am
I have implemented a site with several languages just as described in the tutorial. But when trying to display text using the _t() function it always is displayed in the default locale language (spanish). I managed to get as far as finding out that this happens because _t() gets the locale from i18n::get_locale() and this function for some reason always returns the default language.
Just for testing I made a function in my Page.php that returns a string with the values of:
And Bingo! On the english version of the page the first function returns es_ES while the second value is en_GB. On the spanish version both return es_ES.
Is this normal? Am I missing something? Can _t() not be used this way?
12 December 2010 at 3:52am
I fixed it by adding
to the init() function of the Page_Controller.
As pointed out in this post http://silverstripe.org/general-questions/show/12186 this behaviour is a little strange and IMHO it should be enabled by default because its not clear in the documentation and being able to use _t() in the Template is kinda stupid when it doesn't work.
If anyone has a nice explanation why this works this way please reply anyway.
3 September 2011 at 12:20am
Thanks for this tip, it helped me out.
This should be working by default, you're right about that.
|Go to Top|