Jump to:

23473 Posts in 18941 Topics by 2878 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: 1121 Views
  • martimiz
    Forum Moderator
    1083 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
    Forum Moderator
    1083 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(){
    $this->LastName = _t('MyPage.DEFAULTS_LASTNAME', 'Enter your lastname');

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.