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.

Data Model Questions /

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

DataObject::get with Translatable ON - SiteTree/Page difference.


Go to End


1600 Views

Avatar
pali

Community Member, 33 Posts

29 December 2011 at 3:25am

Hello,

im using this really simple setup, but im surprised with odd behaviour.

This code will return only localized pages:

return DataObject::get("SiteTree");

this is returning all pages - doesn't care about locale:

return DataObject::get("Page");

SS version:
SS 2.4.6

mysite/_config.php:

Translatable::set_default_locale('en_US');
Object::add_extension('SiteTree','Translatable');
Object::add_extension('SiteConfig','Translatable');
Translatable::set_allowed_locales(array('en_US','ru_RU'));

mysite/code/Page.php >> Page_Controller:

...

public function init() {
		
		parent::init();        
		
		if($this->dataRecord->hasExtension('Translatable')) {
			i18n::set_locale($this->dataRecord->Locale);
			setlocale(LC_TIME, $this->dataRecord->Locale . ".utf8"); 
		}	
...
}

...

Is this standard behaviour?

Regards

Pali