7913 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » Translatable Dataobjects - any working solution out there?
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 1322 Views |
-
Translatable Dataobjects - any working solution out there?

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!
Patte
-
Re: Translatable Dataobjects - any working solution out there?

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.
-
Re: Translatable Dataobjects - any working solution out there?

2 June 2010 at 8:54pm
patte,
may you remember this post:
http://www.silverstripe.org/dataobjectmanager-module-forum/show/280629do you tried that out? I use translateable dataobjects using this hack ... but not used in SS24 yet ...
daniel
-
Re: Translatable Dataobjects - any working solution out there?

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.
Thanks
patte
-
Re: Translatable Dataobjects - any working solution out there?

4 June 2010 at 3:04am Last edited: 4 June 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:
http://dev.247activemedia.netstandart 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:
http://dev.247activemedia.net/companies
http://dev.247activemedia.net/companies-tr-TR
http://dev.247activemedia.net/companies-en-USand here is my code:
mysite/_config.php
<?php
global $project;
$project = 'mysite';global $databaseConfig;
$databaseConfig = array(
"type" => 'MySQLDatabase',
"server" => 'xxx',
"username" => 'xxx',
"password" => 'xxx',
"database" => 'xxx',
"path" => '',
);Director::set_dev_servers(array(
'localhost',
'127.0.0.1'
));MySQLDatabase::set_connection_charset('utf8');
SSViewer::set_theme('blackcandy');
i18n::enable();
i18n::set_locale('de_DE.UTF-8');
Translatable::enable();
Translatable::set_default_lang('de');
SiteTree::enable_nested_urls();
Director::set_environment_type("dev");
DataObject::add_extension('SiteConfig', 'CustomSiteConfig');mysite/company.php
<?php
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')
);
}
}mysite/CompanyPage.php
<?php
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(
$this,
'Companies',
'Company',
array(
'CompanyName' => 'CompanyName',
'CompanyLogo' => 'CompanyLogo'
),
'getCMSFields_forPopup'
));
return $f;
}}
class CompanyPage_Controller extends Page_Controller {
public function init() {
parent::init();
}
}themes/blackcandy/templates/Layout/CompanyPage.ss
<div class="typography">
<% if Menu(2) %>
<% include SideBar %>
<div id="Content">
<% end_if %><% if Level(2) %>
<% include BreadCrumbs %>
<% end_if %>
<h2>$Title</h2>
<% control Companies %>
$CompanyName<br />
$CompanyLogo<br />
<br />
<hr />
<br />
<% end_control %>
<% if Menu(2) %>
</div>
<% end_if %>
</div>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.
daniel
-
Re: Translatable Dataobjects - any working solution out there?

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 ;-)
patte
-
Re: Translatable Dataobjects - any working solution out there?

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() {
parent::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.
| 1322 Views | ||
|
Page:
1
|
Go to Top |


