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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Translatable Dataobjects - any working solution out there?

Go to End

7 Posts   1893 Views


Community Member, 63 Posts

1 June 2010 at 3:12am

Hey guys,

it has been asked many times before, I think - unfortunately I couldn`t find any working solution at all. I am using SS24 and I have dataobjects which should be translated into two different languages.

I tried using some patches, different SS and DOM versions. I think I had a running setup with SS24RC2... could that be?

I really need a working solution for translatable dataobjects...please, does anyone have a tip for that? I do not need to use SS24 - if it is working I could also use an older version.

Thank much in advance!



Forum Moderator, 4102 Posts

1 June 2010 at 11:40am

I don't believe it's a DataObjectManager issue. I think it's more that SS in general does not decorate DataObjects with the Translatable features -- only SiteTree.

If you do find something, post it here, because I'm anxious to get that working, as well.


Community Member, 175 Posts

2 June 2010 at 8:54pm


may you remember this post:

do you tried that out? I use translateable dataobjects using this hack ... but not used in SS24 yet ...



Community Member, 63 Posts

2 June 2010 at 9:08pm

Hi Daniel,

thanks again for that hint.

It didn`t work.... I tried using that patch but unfortunately with no success. I used SS2.3 and modified CMSmain.php but I just got a blank dataobject manager screen....

For you it`s working - can you please specify your SS an DOM version? I`ll give it another try and post my results.




Community Member, 175 Posts

4 June 2010 at 3:04am

Edited: 04/06/2010 3:06am

hi patte,

DOM and translateable is working for me now (with latest stable SS 2.4 + DOM #revision: 399) without any hacking ...

I setup a test:

standart language is german. if you go to "companies" you see the german page with 2 entries,
made with DOM. each entry has a headline and an image.

if you look at the source code of the company page you can see that translatable insertet 2 lines of
code in the head section -> alternate languages for this page

<link rel="alternate" type="text/html" title="Companies" hreflang="tr-TR" href="/companies-tr-TR/" />
<link rel="alternate" type="text/html" title="Companies" hreflang="en-US" href="/companies-en-US/" />

so I have 3 versions with 3 different laguages now:

and here is my code:



global $project;
$project = 'mysite';

global $databaseConfig;
$databaseConfig = array(
	"type" => 'MySQLDatabase',
	"server" => 'xxx', 
	"username" => 'xxx', 
	"password" => 'xxx', 
	"database" => 'xxx',
	"path" => '',


DataObject::add_extension('SiteConfig', 'CustomSiteConfig');


class Company extends DataObject

	static $db = array (
		'CompanyName' => 'Varchar',
	static $has_one = array (
		'CompanyLogo' => 'Image',
		'CompanyPage' => 'CompanyPage'
	public function getCMSFields_forPopup()
		return new FieldSet(
			new TextField('CompanyName'),
			new ImageField('CompanyLogo')



class CompanyPage extends Page {
	static $db = array(
	static $has_one = array(
	static $has_many = array (
		'Companies' => 'Company'
	public function getCMSFields()
		$f = parent::getCMSFields();
		$f->addFieldToTab("Root.Content.Companies", new DataObjectManager(
				'CompanyName' => 'CompanyName',
				'CompanyLogo' => 'CompanyLogo'
		return $f;

class CompanyPage_Controller extends Page_Controller {

	public function init() {


<div class="typography">
	<% if Menu(2) %>
		<% include SideBar %>
		<div id="Content">
	<% end_if %>

	<% if Level(2) %>
	  	<% include BreadCrumbs %>
	<% end_if %>
		<% control Companies %>
			$CompanyName<br />
			$CompanyLogo<br />
			<br />
			<hr />
			<br />
		<% end_control %>	

	<% if Menu(2) %>
	<% end_if %>

with SS 2.3.6 this dont worked as now with SS 2.4, I need hack with old versions.

there is just one little thing. for example, if you add an entrie for the germany page and then click on the "Translations" Tab
and then switch to an turkish language, in the SS main window the DOM shows you the german entries. so may you think that
dont work, but if you reload your browser or just reload the page DOM shows the correct entries for the current language.

I can send you a login to this test-enviroment if you like, just give me your email.



Community Member, 63 Posts

7 June 2010 at 8:07pm

Hi Daniel,

thanks for the good news! I`ve checked your demo and it works nearly perfect.

I used your config example to rebuild an existing project without success - perhaps i missed something. I can see both dataobjects (german/english) within SilverStripe but on the webpage itself only the primary languages objects are visibible.

I think have to start with a new database to prevent making errors on a trial and error basis. I`ll keep you informed whats happening.

Best greatings from Cologne ;-)



Community Member, 288 Posts

7 June 2010 at 8:40pm

If you use the CMSMain hack together with the latest version of SilverStripe and DOM you shouldn't need to do much else. The only thing I had to do was to make sure that the Locale got set properly when the data objects are being saved with onBeforeWrite.

I run this code on all my data objects that have Translatable on them

public function onBeforeWrite() {
	$this->Locale = Translatable::get_current_locale();

This code is in Translatable as well but for some reason it doesn't work properly on data objects.