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.net
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:
http://dev.247activemedia.net/companies
http://dev.247activemedia.net/companies-tr-TR
http://dev.247activemedia.net/companies-en-US
and 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