Jump to:

5450 Posts in 1672 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Custom login & translatable

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

Page: 1
Go to End
Author Topic: 759 Views
  • micschk
    Avatar
    Community Member
    18 Posts

    Custom login & translatable Link to this post

    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?

    759 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.