Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

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

translate static $defaults question [SOLVED]


Reply

2 Posts   1131 Views

Avatar
martimiz

28 January 2010 at 2:45am (Last edited: 28 January 2010 6:42am), Forum Moderator, 1095 Posts

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

Avatar
martimiz

28 January 2010 at 6:38am Forum Moderator, 1095 Posts

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');
}