Jump to:

23451 Posts in 18899 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » [SOLVED] Translation of /Security

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

Page: 1
Go to End
Author Topic: 633 Views
  • xini
    Avatar
    Community Member
    8 Posts

    [SOLVED] Translation of /Security Link to this post

    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...

  • xini
    Avatar
    Community Member
    8 Posts

    Re: [SOLVED] Translation of /Security Link to this post

    Anyone an idea?

  • xini
    Avatar
    Community Member
    8 Posts

    Re: [SOLVED] Translation of /Security Link to this post

    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.

    633 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.