I have a task to localize my custom portlet. I'm trying to trick it with hook. I read that I should create hook.xml configuration and property file in my portlet project
<?xml version="1.0"?>
<!DOCTYPE hook PUBLIC "-//Liferay//DTD Hook 6.2.0//EN"
"http://www.liferay.com/dtd/liferay-hook_6_2_0.dtd">
<hook>
<language-properties>resources/language.properties</language-properties>
</hook>
Ok. But how can I use it for my custom portlet with custom field? For example I have jsp:
<c:choose>
<c:when test="${status.equals('captchaError')}">
Captcha error //How can I localize it?
<br />
</c:when>
<c:when test="${status.equals('numberError')}">
Number error //How can I localize it?
<br />
</c:when>
<c:when test="${status.equals('success')}">
Message send //How can I localize it?
<br />
</c:when>
</c:choose>
I hope my question is clear and you will help me!
Define you messages as key-value pair in language.properties file.
eg number-error= Number Error
And use liferay-ui:message tag to get message values. You have to declare taglib for liferay-ui tags.
eg <liferay-ui:message key='number-error'/>
This tag will display value for number-error key from language properties file.
Hope this helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.