Jump to:

23372 Posts in 18175 Topics by 2865 members

General Questions

SilverStripe Forums » General Questions » translate static $defaults question [SOLVED]

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: 1110 Views
  • martimiz
    Avatar
    Forum Moderator
    1067 Posts

    translate static $defaults question [SOLVED] Link to this post

    Hi all,

    I'm struggling to find the right way to translate a page's static $defaults array.

    I thought I found something with provideI18nEntities(), but although that works with Textcollection and puts the correct translation array in the mysite/lang/en_US.php file, this translation still never shows in the CMS...

    Am I missing something? Is there maybe another way to do this?

    I'm on 2.3.4

  • martimiz
    Avatar
    Forum Moderator
    1067 Posts

    Re: translate static $defaults question [SOLVED] Link to this post

    Right, got it - sometimes it seems I only ever find things after I posted the question :

    You don't use static $defaults = array(...);

    You use the populateDefaults() method instead. Something like

    public function populateDefaults(){
    parent::populateDefaults();
    $this->LastName = _t('MyPage.DEFAULTS_LASTNAME', 'Enter your lastname');
    }

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