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.

Customising the CMS /

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

Adding an extra DB field disables translations tab


Go to End


2 Posts   1502 Views

Avatar
Hypnus

Community Member, 11 Posts

9 December 2010 at 2:45am

Hi,

I'm kind of a newbie and maybe my question is dumb but i can't find a solution for my problem.
I am trying to translate my site but when i extend my Page class with an extra field and add it to the CMSFileds the Translations tab disappears from the CMS, and I cannot translate the page.
I've added the translations method _t() to the label of the field but still nothing.

I am using SilverStripe 2.4.3 with MYSQL and what I've setup:

My config file has:
-------------------------- _config.php --------------------------------------------------------
// Enable Translatable
Object::add_extension('SiteTree', 'Translatable');
Object::add_extension('SiteConfig', 'Translatable');

// Default locale language
Translatable::set_default_locale("en_US");

// Enable locale
i18n::enable();
// Set the default site locale
i18n::set_locale('en_US');

// Define allowed locales overriding those present in i18n::$common_locales
global $allowed_locales;
$allowed_locales = array(
'en_US' => array('English', 'English'),
'de_DE' => array('German', 'Deutsch')
);
i18n::$common_locales = $allowed_locales;
------------------------------------------------------------------------------------------------------

I've added to my Page.php in the controller init function and the extension:
--------------------------------- Page.php --------------------------------------------------------
public static $extensions = array(
"Translatable"
);

...... Page_Controller.....

if($this->dataRecord->hasExtension('Translatable')) {
i18n::set_locale($this->dataRecord->Locale);
}

------------------------------------------------------------------------------------------------------

Thanks in advance.

Avatar
Hypnus

Community Member, 11 Posts

9 December 2010 at 10:17pm

Edited: 09/12/2010 11:28pm

Ok, i was wrong with the last reply, the issue is with the disable/enable the CMSFieldsExtension :

So do not use something like this (in the getCMSFields() method, but not only there):

SiteTree::disableCMSFieldsExtensions();
$fields = parent::getCMSFields();
SiteTree::enableCMSFieldsExtensions();

just simply:

$fields = parent::getCMSFields();

will do it just fine.

Thanks and sorry if i got anyone confused.