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

Language translation in SS 2.3.3 (Images & DataObjectManager ComplexTableField)


Go to End


4 Posts   2013 Views

Avatar
Terminator4

Community Member, 81 Posts

20 August 2009 at 10:12pm

Hey guys,

I am really impressed with the way in which the language translation functionality works in the latest SS. However, I am not sure how to do the following:

1) I would be able to inherit images from the default locale and use it for other languages in the backoffice and frontend

2) How would I be able to make language translations work for ComplexTableFields.

3) How would I allow these translations to be shown properly a table and be inherited for use in drop downs

Avatar
Ingo

Forum Moderator, 801 Posts

25 August 2009 at 9:31am

I don't get what you mean with "inherited" in 1) and 3), sorry.

> 2) How would I be able to make language translations work for ComplexTableFields.
http://open.silverstripe.com/ticket/4435

Grüße
Ingo

Avatar
Terminator4

Community Member, 81 Posts

26 August 2009 at 8:34pm

Hi Ingo,
Thank you for that ComplexTable fix.

With regard to inheriting data in the database I will clarify with the following example:
1) Product X has many images
2) Product X has many colours
3) Product X has many categories it falls into

I need to translate Product X and retain 1-3

Avatar
Ingo

Forum Moderator, 801 Posts

27 August 2009 at 8:23am

Edited: 27/08/2009 8:24am

Ah, of course. Thats currently not possible, see http://open.silverstripe.com/ticket/3722

For a has_one relationship, you can work around it by overloading the getters/setters for the field.
For has_many/many_many, you could try overloading it and just returning the relations for any of the translations. A bit hacky, because it means that you still associate the objects with a translation, rather than the original:

class Product extends DataObject {
	$has_many = array('Colors'=>'Color');
	function Colors() {
		$ids = implode(',',$this->getTranslations()->column('ID'));
		return $this->getComponents('Colors', sprintf('"Color"."ProductID" IN %s', $ids));
	}
}
class Color extends DataObject {
	$has_one = array('Product'=>'Product');
}

You might get into trouble with the existing "ProductID = X" check generated by getComponents(), in whcih case you'd have to manipulate the query directly through getComponentsQuery(). Also note that the code doesn't have any error checking for empty sets etc.