留言板

Liferay 7 Language Properties

Jatinderveer Singh,修改在6 年前。

Liferay 7 Language Properties

New Member 帖子: 21 加入日期: 17-2-24 最近的帖子
So i have a JSF portlet that I have migrated from Liferay6.2 to Liferay7. Now everything else seems to be working just fine barring one or two migration problems, nothing major. Now only major item I am concerned about right now is Language properties file usage. I donot reallyt know where to put the language files for the portlet to be able to read it. In 6.2 we could put it in Liferay-hook.xml but in migration that file is not created and hence i am not sure where to put it.
Do i go ahead and create a Liferay-hook.xml file next to my portlet.xml? -- Done that the deployment gives error regarding unable to register hook.
Maybe i am not doing something right. Could not find any KB on community as well.
Here is the cause for exception getting printed. I am unable to wrap my head around it.

Caused by: com.liferay.portal.kernel.xml.DocumentException: Error on line 4 of document  : Document root element "hook", must match DOCTYPE root "liferay-portlet-app". Nested exception: Document root element "hook", must match DOCTYPE root "liferay-portlet-app".
	at com.liferay.portal.xml.SAXReaderImpl.read(SAXReaderImpl.java:410)
	at com.liferay.portal.xml.SAXReaderImpl.read(SAXReaderImpl.java:428)
	at com.liferay.portal.kernel.xml.UnsecureSAXReaderUtil.read(UnsecureSAXReaderUtil.java:74)
	at com.liferay.portal.deploy.hot.HookHotDeployListener.doInvokeDeploy(HookHotDeployListener.java:461)
	at com.liferay.portal.deploy.hot.HookHotDeployListener.invokeDeploy(HookHotDeployListener.java:271)
	... 68 more
Caused by: org.dom4j.DocumentException: Error on line 4 of document  : Document root element "hook", must match DOCTYPE root "liferay-portlet-app". Nested exception: Document root element "hook", must match DOCTYPE root "liferay-portlet-app".
	at org.dom4j.io.SAXReader.read(SAXReader.java:482)
	at org.dom4j.io.SAXReader.read(SAXReader.java:365)
	at com.liferay.portal.xml.SAXReaderImpl.read(SAXReaderImpl.java:407)
	... 72 more


My Liferay-hook.xml file is like this:

<!--?xml version="1.0"?-->


<hook>
	<language-properties>content/Language_en_US.properties</language-properties>
	<language-properties>content/Language_es.properties</language-properties>
    <language-properties>content/Language_hu.properties</language-properties>	
    <language-properties>content/Language_de.properties</language-properties>	
    <language-properties>content/Language_zh_CN.properties</language-properties>	
</hook>


I did modify the doctype attribute to be Liferay 7 DTD maybe that is causing this but there is no compile time warning or error in these files.
thumbnail
Neil Griffin,修改在6 年前。

RE: Liferay 7 Language Properties

Liferay Legend 帖子: 2655 加入日期: 05-7-27 最近的帖子
Here is an example liferay-hook.xml file that we have in one of our JSF demo portlets for Liferay Portal 7.0 -- please compare it with yours to see if there are any significant differences. Also, you will probably need to include the following dependency to make it work:
<dependency>
    <groupid>com.liferay.faces</groupid>
    <artifactid>com.liferay.faces.portal</artifactid>
    <version>3.0.0</version>
</dependency>
Jatinderveer Singh,修改在6 年前。

RE: Liferay 7 Language Properties

New Member 帖子: 21 加入日期: 17-2-24 最近的帖子
Thanks Neil. Looks like it is working now. I guess it did not know about the Liferay Dependency of pom.xml.
Jatinderveer Singh,修改在6 年前。

RE: Liferay 7 Language Properties

New Member 帖子: 21 加入日期: 17-2-24 最近的帖子
Hi Neil,
I observed that once i use this sort of configuration to get the Languages going there is a hook being registered related to my portlet. Do i need to take care of this hook for every new deployment? From somewhere in Gogo shell maybe?