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.

Customising the CMS /

Custom login & translatable


Reply


835 Views

Avatar
micschk

Community Member, 19 Posts

28 April 2011 at 4:12am

I've build a multilanguage-site (NL & FR, using translatable) and I created a custom login form

class CustomLoginForm extends MemberLoginForm

Everything works fine, but when a visitor selects the French locale, the login-form part is always displayed in Dutch (NL). The header & footer are all in french, and even $Locale outputs 'fr_FR'

In page.php Page_Controller::init():

if($this->dataRecord->hasExtension('Translatable')) {
i18n::set_locale($this->dataRecord->Locale);
}
// Set locale for PHP, dates etc;
setlocale(LC_TIME, Translatable::get_current_locale() . ".UTF8");

Even when I set the locale to French in _config.php, the form is still shown in Dutch;

i18n::set_locale('fr_FR');

I ended up setting the locale again within the custom loginform file, which works (at least a preliminary fix);

<?php

// Set locale again, for some reason the locale from page_controller isn't adhered to...
i18n::set_locale(Translatable::get_current_locale());

class CustomLoginForm extends MemberLoginForm { ...

Is this the way translations are supposed to work? Or have I done something wrong?