How to localize a custom type created in trainingcore-items.xml in Hybris?

Viewed 1380

I have created a custom type in items.xml. How can I localize the item type? Where should I use the localized keyword for the item type to be localized?

    <itemtype code="Service" autocreate="true" generate="true">
           <deployment typecode="23456" table="Service"/>
            <attributes>
                <attribute qualifier="code" type="java.lang.String" autocreate="true" generate="true">
                    <persistence type="property"/>
                    <description>Service Code</description>
                    <modifiers unique="true" read="true" write="true"/>
                </attribute>
                <attribute qualifier="serviceType" type="ServiceType" autocreate="true" generate="true">
                    <persistence type="property"/>
                    <description>Service Type</description>
                    <modifiers read="true" write="true"/>
                </attribute>
                <attribute qualifier="years" type="java.lang.Integer" autocreate="true" generate="true">
                    <persistence type="property"/>
                    <description>Service Years</description>
                    <modifiers read="true" write="true"/>
                </attribute>
    </itemtype>
3 Answers

The answer that you accepted is wrong.

You shouldn't do type="localized:Service". What this does is let you set a different Service value for each language.

If what you wanted to do was add different labels/localization for the Service type, then what you did in your other question is correct.

For English localization/translation, define the localization in trainingcore_locales_en.properties:

type.Service.name=Service
type.Service.code.name=code
type.Service.serviceType.name=serviceType
type.Service.years.name=years

type.ServiceType.name=ServiceType
type.ServiceType.Basic.name=Basic
type.ServiceType.BasicOnsite.name=BasicOnsite
type.ServiceType.Advanced.name=Advanced

For German translation, set the translation in trainingcore_locales_de.properties.

Reference:

@geffchang's answer is correct. @Parvesh is wrong. It is not possible to have automagically localized Service just by adding localized:.

To do that you need to create new map-type:

<maptype code="localized:Service"
     argumenttype="Language"
     returntype="Service"
     autocreate="true"
     generate="false"/>

Do you mean you want to add this service as a localized attribute in another item type?

that can be done with something like this.

`   <attribute qualifier="service" type="localized:Service">
                    <persistence type="property" />
                </attribute>`
Related