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.

General Questions

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

[SOLVED] Translation of /Security


3 Posts   651 Views


26 March 2012 at 7:00pm Community Member, 8 Posts

I have a multi lingual site and everything works fine exept the translation of the login form.

I use SS 2.4.7 with the following config:

Object::add_extension('SiteTree', 'Translatable');
Object::add_extension('SiteConfig', 'Translatable');

I need the users to be able to login on the front end, so I created a link to /Security/login. But whatever locale the site currently is, the login form is always displayed in german. Even if I add the locale to the link e.g. /Security/login?locale=en_EN the login form always is in german.
Is there a possibility to get Security translated as well? or am I just doing something wrong?

Thank youvery much for your help...


31 March 2012 at 12:39pm Community Member, 8 Posts

Anyone an idea?


3 April 2012 at 12:47pm Community Member, 8 Posts

simon_w had a solution for this, thanks again!

Translatable loads the locale automatically, i18n doesn't. To get the page loaded in the correct locale, you have to add the following in you _config ():

if(!empty($_GET['locale'])) i18n::set_locale($_GET['locale']);

Security loads the content in a fake page. In that case you can check the ID to be <0.

if ($this->ID < 0) {
   if(!empty($_GET['locale'])) i18n::set_locale($_GET['locale']);

It's not the perfect solution and I had to sub class Security and MemberLoginForm to rewrite all the links that didn't include the locale, but it works so far.