Liferay:本地化布局模板名称

时间:2017-08-29 06:56:10

标签: liferay hook liferay-6 resourcebundle liferay-6.2

我编写了一个maven模块,其中包含liferay的自定义布局。布局工作正常,但我也希望它的名称可以用几种语言翻译。 这是我的liferay-layout-templates.xml文件:

<?xml version="1.0"?>
<!DOCTYPE layout-templates PUBLIC "-//Liferay//DTD Layout Templates 6.2.0//EN" "http://www.liferay.com/dtd/liferay-layout-templates_6_2_0.dtd">

<layout-templates>
<custom>
    <layout-template id="2_columns_layout-75_25" name="myLayout">
        <template-path>/2_columns_layout-75_25/2_columns_75_25.tpl</template-path>
        <wap-template-path>/2_columns_layout-75_25/2_columns_75_25.wap.tpl</wap-template-path>
        <thumbnail-path>/2_columns_layout-75_25/2_columns_75_25.png</thumbnail-path>
    </layout-template> 
</custom>
</layout-templates>

我尝试删除name属性并添加语言键(与我的模板ID相同)和值到我的钩子模块,但它不起作用。

1 个答案:

答案 0 :(得分:1)

起初我倾向于声明没有内置的方法来本地化布局模板。但是,我查找了有问题的JSP(在Liferay的html/portlet/layouts_admin/layout/layout_templates_list.jsp中)并找到了以下行(缩短并编辑过):

<%= HtmlUtil.escape(LanguageUtil.get(locale, 
    "layout-template-" + layoutTemplateName, layoutTemplateName)) %>

所以看起来你需要用来翻译布局模板名称的本地化键需要以“layout-template-”开头,然后是布局模板自己的名称,例如:给出你问题中的xml:layout-template-myLayout=My first localized layout template