Jump to:

5513 Posts in 1732 Topics by 1218 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Language translation in SS 2.3.3 (Images & DataObjectManager ComplexTableField)

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

Page: 1
Go to End
Author Topic: 1471 Views
  • Terminator4
    Avatar
    Community Member
    81 Posts

    Language translation in SS 2.3.3 (Images & DataObjectManager ComplexTableField) Link to this post

    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

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: Language translation in SS 2.3.3 (Images & DataObjectManager ComplexTableField) Link to this post

    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

  • Terminator4
    Avatar
    Community Member
    81 Posts

    Re: Language translation in SS 2.3.3 (Images & DataObjectManager ComplexTableField) Link to this post

    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

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: Language translation in SS 2.3.3 (Images & DataObjectManager ComplexTableField) Link to this post

    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.

    1471 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.