ForExample
ForExample

Reputation: 33

Liferay: localize layout template names

I have written a maven module, which contains my custom layout for liferay. The layout works fine but I also want it's name to be translated in a few languages. Here's my liferay-layout-templates.xml file:

<?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>

I tried to delete name attribute and add language keys(which were the same to my template id) and values to my hook module, but it didn't work.

Upvotes: 1

Views: 316

Answers (1)

Olaf Kock
Olaf Kock

Reputation: 48057

At first I was inclined to state that there's no built-in way to localize layout templates. However, I've looked up the JSP in question (in Liferay's html/portlet/layouts_admin/layout/layout_templates_list.jsp) and found the following line (shortened and edited):

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

So it looks like the localization keys that you'll need to use for translating your layout-template's name needs to be starting with "layout-template-" followed by the layout template's own name, e.g. given the xml from your question: layout-template-myLayout=My first localized layout template

Upvotes: 1

Related Questions