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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

[SOLVED] Translation of /Security


Go to End


3 Posts   1354 Views

Avatar
xini

Community Member, 8 Posts

26 March 2012 at 7:00pm

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:

i18n::set_locale('de_DE');
Translatable::set_default_locale('de_DE');
Translatable::set_allowed_locales(
	array(
		'de_DE',
		'fr_FR',
		'it_IT',
		'en_GB',
	)
);
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...

Avatar
xini

Community Member, 8 Posts

31 March 2012 at 12:39pm

Anyone an idea?

Avatar
xini

Community Member, 8 Posts

3 April 2012 at 12:47pm

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.
Page_Controller.init():

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.