Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
Js Jean
Issue in Translating the title of a portlet
October 14, 2010 10:00 AM
Answer

Js Jean

Rank: New Member

Posts: 20

Join Date: July 26, 2010

Recent Posts

Hi,

I have a bundle Liferay 5.2.3, for which I develop portlets.

I can translate the text inside my portlets, after having put the required Language_*.properties in $LIFERAY_HOME/tomcat/webapps/ROOT/WEB-INF/classes/content, using the tags <liferay-ui:message key="id.of.text" /> in the code of the JSP.

But so far I have not managed to translate the title of my portlet, defined in portlet.xml.
I have put the following line in the Language_*.properties :

1javax.portlet.title.chat-portlet=Title to show


chat-portlet is the "portlet-name" of the portlet in question.

Once this is done, what should I put in the tag <title> in portlet.xml in order to take the Language_*.properties into account ? I have already tested "chat-portlet", "@chat-portlet@", ... but without success.

Thank you,

Sylvain
Mohd Hanafi
RE: Issue in Translating the title of a portlet
October 14, 2010 11:42 PM
Answer

Mohd Hanafi

Rank: Junior Member

Posts: 83

Join Date: January 17, 2010

Recent Posts

Hi,

Maybe this entry can help to solve your problem.


Thanks.
Js Jean
RE: Issue in Translating the title of a portlet
October 15, 2010 12:37 AM
Answer

Js Jean

Rank: New Member

Posts: 20

Join Date: July 26, 2010

Recent Posts

Hi,

Thank you for answering me.

But this blog only shows how to choose a particular language from the interface of the portal.
My problem is I don't know how to configure a portlet to have its title translation available. The title in question is defined in portlet.xml :

1<portlet-info>
2    <title>What should I put here to translate my title ?</title>
3    <short-title>short title</short-title>
4    <keywords>keywords</keywords>
5</portlet-info>



The translation in itself is defined in various Language_*.properties, located in LIFERAY_HOME\webapps\ROOT\WEB-INF\classes\content, for example here is Language-ext_en.properties :

1javax.portlet.chat.linktext=Open the chat window.
2javax.portlet.title.chat-portlet=Link to the chat


I would like to use the translation for javax.portlet.title.chat-portlet in the <title> tag of portlet.xml.

Thanks,

Sylvain
Oliver Bayer
RE: Issue in Translating the title of a portlet
October 15, 2010 1:17 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 883

Join Date: February 18, 2009

Recent Posts

Hi Sylvain,

as you can see inside the portlet.xml of the chat portlet this portlet has the portlet-name "1". So you should be able to override this name by adding the following line in your language files:
1javax.portlet.title.1=My new chat portlet name

HTH Oli
Js Jean
RE: Issue in Translating the title of a portlet
October 15, 2010 2:13 AM
Answer

Js Jean

Rank: New Member

Posts: 20

Join Date: July 26, 2010

Recent Posts

Hi,

I'm sorry, there was a misunderstanding due to the name of my portlet, which has nothing to do with the official Liferay chat portlet.

Consider that I have a lambda portlet, in which I need to translate the title ...

I have seen another post about the subject : http://www.liferay.com/community/forums/-/message_boards/message/5373092.

So, according to this post, and to what is already done in a portlet-ext.xml from Liferay, in my portlet.xml I tried to replace :
1
2<portlet-info>
3    <title>The title to translate</title>
4    <short-title>short-title</short-title>
5    <keywords>short-title</keywords>
6</portlet-info>


by :

1<resource-bundle>com.liferay.portlet.StrutsResourceBundle</resource-bundle>


and then as it did not work I also tried :

1<resource-bundle>com.liferay.portlet.PortletResourceBundle</resource-bundle>


but without success.

I add that in the pom.xml of my portlet I have a dependency to portal-impl, which contains these 2 classes.

In both cases above, if I try to add an application in Liferay, the section Sample does not appear (and though it has other portlets than mine ...), and I have the following Stack trace :


 1
 208:10:17,051 ERROR [IncludeTag:79] Current URL /c/portal/render_portlet generate
 3s exception: An exception occurred processing JSP page /html/portlet/layout_conf
 4iguration/view_category.jsp at line 84
 5
 681:     }
 782: }
 883:
 984: portlets = ListUtil.sort(portlets, new PortletTitleComparator(application, l
10ocale));
1185:
1286: if ((categories.size() > 0) || (portlets.size() > 0)) {
1387: %>
14
15
16Stacktrace:
1708:10:17,051 ERROR [IncludeTag:165] java.util.MissingResourceException: Can't fi
18nd resource for bundle com.liferay.portlet.PortletResourceBundle, key javax.port
19let.title
20        at java.util.ResourceBundle.getObject(ResourceBundle.java:325)
21        at java.util.ResourceBundle.getString(ResourceBundle.java:285)
22        at com.liferay.portal.util.PortalImpl.getPortletTitle(PortalImpl.java:19
2375)
24        at com.liferay.portal.util.PortalUtil.getPortletTitle(PortalUtil.java:60
251)
26        at etc ...



If you have any idea with these new informations, thanks for your help !

Sylvain
Oliver Bayer
RE: Issue in Translating the title of a portlet
October 15, 2010 12:37 PM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 883

Join Date: February 18, 2009

Recent Posts

Hi,

ok so you're also developing your portlet outside of liferay?

As Corné said in the thread you mentioned you should write your portlet.xml as follows:
1<portlet>
2<resource-bundle>com.foo.Resource</resource-bundle>
3</portlet>

Where com.foo.Resource is the path to the resource file - here the language files. Only a hint: The enclosing tag is <portlet> and not <portlet-info>.

If you would use the liferay sdk the correct folder structure and the xmls would be created by the ant task and therefore development is a little easier.

Oli