Search code examples
sap-commerce-cloud

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


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>

Solution

  • 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: