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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

translate static $defaults question [SOLVED]


Go to End


2 Posts   1494 Views

Avatar
martimiz

Forum Moderator, 1391 Posts

28 January 2010 at 2:45am

Edited: 28/01/2010 6:42am

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

Forum Moderator, 1391 Posts

28 January 2010 at 6:38am

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