如何本地化在 Hybris 的 trainingcore-items.xml 中创建的自定义类型?

问题描述

我在 items.xml 中创建了一个自定义类型。 如何本地化项目类型?对于要本地化的项目类型,我应该在哪里使用 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>

解决方法

您接受的答案是错误的。

你不应该做type="localized:Service"。这样做的目的是让您为每种语言设置不同的服务值。

如果您想要为服务类型添加不同的标签/本地化,那么 what you did in your other question 是正确的。

对于英语本地化/翻译,请在 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

对于德语翻译,请在 trainingcore_locales_de.properties 中设置翻译。

参考:

,

您的意思是要将此服务添加为另一种商品类型的本地化属性吗?

可以用这样的东西来完成。

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