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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Making an element NOT translatable


Reply


3 Posts   886 Views

Avatar
Futureal

Community Member, 9 Posts

1 April 2011 at 3:49am

I have a dual language website,
and I have added various extra Text fields to my Page class, specific to the website I'm making.
However, I want these extra fields to be non-translatable, so I want them to have identical content for both languages, and not have to update the field in both languages if something changes.

How can I do this?
By default, it translates everything I add to a class...

Thanks in advance.

Avatar
Futureal

Community Member, 9 Posts

5 April 2011 at 8:44pm

It's basically an easy question: I have a multilingual website, and all I want is for some fields (like a custom Text or something simple) to be *not* translated, so I want it to be identical in both languages?

Anyone please?

Avatar
Ingo

Forum Moderator, 801 Posts

17 April 2011 at 10:31pm

Sorry, thats not possible with the current database row setup. A quick workaround is to create a custom getter, and always retrieve the main translation value.

function getMyUntranslatedField() {
$t = $this->getTranslation('en_US');
return $t ? $t->getField('MyUntranslatedField') : null;
}

function getCMSFields() {
$fields = parent::getCMSFields();
// avoid the field being edited on translations
if($this->Locale != 'en_US') $fields->fieldByName('MyUntranslatedField')->makeReadonly();
return $fields;
}

I know its a big limitation of the datamodel, it was a tradeoff...
I'm looking for help adding this "field exclusion" mechanism to the core if you're keen.