如何在 Hybris 中本地化在 trainingcore-items.xml 中创建的自定义类型?
How to localize a custom type created in trainingcore-items.xml in Hybris?
我在 items.xml 中创建了自定义类型。
如何本地化项目类型?对于要本地化的项目类型,我应该在哪里使用本地化关键字?
<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>
您是说要将此服务添加为其他项目类型中的本地化属性吗?
可以用这样的东西来完成。
` <attribute qualifier="service" type="localized:Service">
<persistence type="property" />
</attribute>`
您接受的答案是错误的。
你不应该这样做 type="localized:Service"
。这样做的目的是让您为每种语言设置不同的服务值。
如果您想为服务类型添加不同的 labels/localization,那么 是正确的。
对于英语 localization/translation,在 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
中设置翻译。
参考:
是正确的。 @Parvesh 错了。仅通过添加 localized:
.
不可能自动本地化服务
为此,您需要创建新的地图类型:
<maptype code="localized:Service"
argumenttype="Language"
returntype="Service"
autocreate="true"
generate="false"/>
我在 items.xml 中创建了自定义类型。 如何本地化项目类型?对于要本地化的项目类型,我应该在哪里使用本地化关键字?
<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>
您是说要将此服务添加为其他项目类型中的本地化属性吗?
可以用这样的东西来完成。
` <attribute qualifier="service" type="localized:Service">
<persistence type="property" />
</attribute>`
您接受的答案是错误的。
你不应该这样做 type="localized:Service"
。这样做的目的是让您为每种语言设置不同的服务值。
如果您想为服务类型添加不同的 labels/localization,那么
对于英语 localization/translation,在 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
中设置翻译。
参考:
localized:
.
为此,您需要创建新的地图类型:
<maptype code="localized:Service"
argumenttype="Language"
returntype="Service"
autocreate="true"
generate="false"/>