Jump to:

22976 Posts in 11702 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » Translatable and PHP language tables

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: 1280 Views
  • karibe
    Avatar
    Community Member
    56 Posts

    Translatable and PHP language tables Link to this post

    Hello

    I'm upgrading my old page based on ss 2.2.3 to new 2.3.3 wit new multilang future.
    The problem is that I have static typed form in page type ContacPage.php with labels like name surname, subject ...
    This problem is common in many cases so I red in doc that there is something like php language tables.
    I made in mysite/lang two files pl_PL.php and en_US.php and in contact form:

    new TextField(_t('ContactForm.NAMESURNAME', "ImiÄ™ i Nazwisko")

    where in pl_PL.php I have :

    $lang['pl_PL']['ContactForm']['NAMESURNAME'] = 'foo:';

    What I'm doing wrong?
    Maybe there is some better way to do same?

  • dendeffe
    Avatar
    Community Member
    135 Posts

    Re: Translatable and PHP language tables Link to this post

    Hmmm I guess this is more or less the same question as my post: http://www.silverstripe.org/general-questions/show/267119#post267119. Basically, more info and examples on the locale files.

  • karibe
    Avatar
    Community Member
    56 Posts

    Re: Translatable and PHP language tables Link to this post

    Yes we need same functionality:)

  • Xeal
    Avatar
    Community Member
    37 Posts

    Re: Translatable and PHP language tables Link to this post

    add this line into your mysite/_config.php file
    Object::add_extension('SiteTree', 'Translatable');

    and then add this to your Page_Controller in mysite/code/Page.php
    if($this->dataRecord->hasExtension('Translatable')) {
       i18n::set_locale($this->dataRecord->Locale);
    }

    That should do the trick

  • dendeffe
    Avatar
    Community Member
    135 Posts

    Re: Translatable and PHP language tables Link to this post

    Thanks Xeal.

    Don’t know if this solves my problem though. I get a blank page if I add that code to the Page_Controller.

  • karibe
    Avatar
    Community Member
    56 Posts

    Re: Translatable and PHP language tables Link to this post

    Cool works for me if pasted in PageController::init() method

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