21278 Posts in 5728 Topics by 2599 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1249 Views |
-
How to change i18::current_lang via URL?

29 April 2010 at 10:02am
Hello,
I am working on a site with 2 languages and it has a language chooser page to choose from 2 different homepages. When a homepage is selected, everything works just fine except 18n strings (I use them in templates via <% _t() %> ). How do I force i18n to look for a correct translation?
Setting the ?locale=... or hreflang=... in URL does not help.Currently I use a dirty hack in HomePage.php index() to check the URLSegment and set locale with i18n::set_locale().
Is there a nicer way to do that or is it just a plain bug that the i18n does not follow the page language setting?Thanks.
Harl
-
Re: How to change i18::current_lang via URL?

29 April 2010 at 8:56pm
Not sure, but try adding this to your config.php:
i18n::set_locale(Translatable::get_current_locale());
-
Re: How to change i18::current_lang via URL?

9 May 2010 at 10:23pm
Thanks! This indeed works as expected! However one would expect that this works automatically. Perhaps a bug in sapphire?
-
Re: How to change i18::current_lang via URL?

10 May 2010 at 7:13pm
Not a bug. I18N and Translatable are independent of each other. I18n is for backend/ui translation where Translatable allows to have website content in different languages. A bit confusing, though.
-
Re: How to change i18::current_lang via URL?

10 May 2010 at 7:32pm
But what about <% _t() %> in templates? That defines page content as well. And this translation ignores page's locale by default. I still consider that code snippet above a hack
| 1249 Views | ||
|
Page:
1
|
Go to Top |

