Reputation: 18848
How do I add additional properties to Liferay.
I don't want to override the existing properties. I would like to add new properties on top of existing properties
I tried in this way, but no luck
<portlet>
<portlet-name>search</portlet-name>
<display-name>Search</display-name>
<portlet-class>org.springframework.web.portlet.DispatcherPortlet</portlet-class>
<init-param>
<name>contextConfigLocation</name>
<value>/WEB-INF/spring-config/search-portlet.xml</value>
</init-param>
<init-param>
<name>config-template</name>
<value>/WEB-INF/view/search/configuration.jsp</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
</supports>
<resource-bundle>Language</resource-bundle>
.............
</portlet>
I have placed Language.properties file under src/main/resources/
However when I try to print <liferay-ui:message key="test-lang-msg" />
I am not getting the value
Language.properties file
test-lang-msg=Testing Language Properties File
Upvotes: 3
Views: 4081
Reputation: 1578
Maven portlet has a different folder structure, so the location of resource bundle for maven portlet is different. There is already a folder called resources for resource-bundles. Put your Language_en.properties directly into this folder.
myportlet/src/main/java
/resources/Language_en.properties
/webapp
Then declare your resource-bundle in portlet.xml like so:
<resource-bundle>Language</resource-bundle>
It will automatically search in the resources folder for your Language bundles.
If you create subfolders (packages), use the "." as separator, e.g. <resource-bundle>resource.Language</resource-bundle>
Upvotes: 0
Reputation: 603
As it was answered, you should add the "resource-bundle" tag correctly. But also, we have to be careful when creating the Resource Bundle file as well.
Create a "resource" package inside of your docroot/WEB-INF/src. Inside of it, create a new file called Language.properties. After that, you are ready to update your portlet.xml file. Find a copy of my portlet.xml below. Pay attention to the way I defined the resource-bundle tag value: resource.Language
<?xml version="1.0"?>
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="2.0">
<portlet>
<portlet-name>birthday</portlet-name>
<display-name>Birthday</display-name>
<portlet-class>
com.test.exercise.customers.portlet.BirthdayPortlet
</portlet-class>
<init-param>
<name>view-template</name>
<value>/html/birthday/view.jsp</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
</supports>
<resource-bundle>resource.Language</resource-bundle>
<portlet-info>
<title>Birthday</title>
<short-title>Birthday</short-title>
<keywords></keywords>
</portlet-info>
<security-role-ref>
<role-name>administrator</role-name>
</security-role-ref>
<security-role-ref>
<role-name>guest</role-name>
</security-role-ref>
<security-role-ref>
<role-name>power-user</role-name>
</security-role-ref>
<security-role-ref>
<role-name>user</role-name>
</security-role-ref>
</portlet>
</portlet-app>
The location of the "resource-bundle" tag also matters within the portlet.xml file. If you check the ../portlet-app_2_0.xsd, you can find a "sequence" element that defines the order of the tags inside your portlet.xml file. Make sure that the "resource-bundle" tag is located in the appropriate place.
I hope this helps anyone running in the same issue when localizing a portlet.
Upvotes: 0
Reputation: 723
Check this out: http://www.liferay.com/community/wiki/-/wiki/Main/Portlet+Localization+-+Outside+Liferay.
If you are still facing issues, I'd suggest simple solution: Create a language hook (as described here http://www.liferay.com/documentation/liferay-portal/6.2/development/-/ai/override-a-language-properties-hook-liferay-portal-6-2-dev-guide-en) for deploying your resource bundles.
Upvotes: 0
Reputation: 4210
Your entry for in portlet.xml is not correct.
Provide it like
<resource-bundle>resource.Language</resource-bundle>
HTH Regards
Upvotes: 2