Foren

Translate portlet name

nathan chantrenne, geändert vor 13 Jahren.

Translate portlet name

New Member Beiträge: 3 Beitrittsdatum: 21.07.10 Neueste Beiträge
Hi everyone,

i am using Liferay portal 5.1 in French and English. My problem is that when using the link "Add Application" i don't know how to show portlet names in any language. In my custom portlets, name is defined in the file portlet.xml like this :


<portlet-info>
	<title>Title</title>
	<short-title>title</short-title>
	<keywords>title</keywords>
</portlet-info>


So, how can i do to have a title that change depending on user locale ?

Thanks in advance.
Alexandre FIEVEE, geändert vor 13 Jahren.

RE: Translate portlet name

New Member Beiträge: 23 Beitrittsdatum: 24.10.08 Neueste Beiträge
Hi,
You've to add translation into the language-ext_fr.properties file, located in "ext-impl/src/content".
Portlet translation title si like this :
javax.portlet.title.myportlet=My portlet
"myportlet" si the name setted in your liferay-portlet-ext.xml.
nathan chantrenne, geändert vor 13 Jahren.

RE: Translate portlet name

New Member Beiträge: 3 Beitrittsdatum: 21.07.10 Neueste Beiträge
My portlets are developped outside Liferay and added to Tomcat as war files, so I don't have any ext-impl folder nor liferay-portlet-ext.xml but for all my portlet I have a file portlet.xml, a file liferay-portlet.xml...
thumbnail
Corné A, geändert vor 13 Jahren.

RE: Translate portlet name

Liferay Legend Beiträge: 1313 Beitrittsdatum: 03.10.06 Neueste Beiträge
add this to your own portlets property files

javax.portlet.short-title=Foor short
javax.portlet.title=Foo title
javax.portlet.keywords=Foo FOO fooeid


and define it in portlet.xml
<portlet>
<resource-bundle>com.foo.Resource</resource-bundle></portlet>
nathan chantrenne, geändert vor 13 Jahren.

RE: Translate portlet name

New Member Beiträge: 3 Beitrittsdatum: 21.07.10 Neueste Beiträge
That's what I was looking for, translation is OK now.

Thank you.
thumbnail
Andew Jardine, geändert vor 12 Jahren.

RE: Translate portlet name

Liferay Legend Beiträge: 2416 Beitrittsdatum: 22.12.10 Neueste Beiträge
Hi,

I have a similar situation, however, I have multiple portlets defined within the same portlet.xml. I am trying to distinguish them using the following key structure --

javax.portlet.title.portlet-name

so that if I have


<portlet>		
		<portlet-name>search</portlet-name>		
		<display-name>Search Portlet</display-name>	
                ...
</portlet>


Then in my resource bundle I am trying to use --

javax.portlet.title.search=Search Portlet

.. but it doesn't seem to be working. I am on Lifreay 6, any tips?

aj.

PS> I should add that I am trying to does this in multiple languages for I have Resources_en, Resources_fr, Resources_es, etc.
thumbnail
Corné Aussems, geändert vor 12 Jahren.

RE: Translate portlet name

Liferay Legend Beiträge: 1313 Beitrittsdatum: 03.10.06 Neueste Beiträge
See this post for example and this one

Maybe it is because you use a forbidden word 'search' emoticon
thumbnail
Ravi Kumar Gupta, geändert vor 12 Jahren.

RE: Translate portlet name

Liferay Legend Beiträge: 1302 Beitrittsdatum: 24.06.09 Neueste Beiträge
Hi Corné,

This is not for all standard portlet or is it? Will this work for Liferay only..??

javax.portlet.title.portlet123=My Portlet


-Ravi
thumbnail
Corné Aussems, geändert vor 12 Jahren.

RE: Translate portlet name

Liferay Legend Beiträge: 1313 Beitrittsdatum: 03.10.06 Neueste Beiträge
Hi Ravi,

AFAIK this is specific to Liferay and not in the JSR 168/286

See for more info:
http://www.liferay.com/community/wiki/-/wiki/Main/Portlet+Localization+-+Outside+Liferay#section-Portlet+Localization+-+Outside+Liferay-Portlet+Title

Ravi Kumar Gupta:
Hi Corné,

This is not for all standard portlet or is it? Will this work for Liferay only..??

javax.portlet.title.portlet123=My Portlet


-Ravi
thumbnail
Ravi Kumar Gupta, geändert vor 12 Jahren.

RE: Translate portlet name

Liferay Legend Beiträge: 1302 Beitrittsdatum: 24.06.09 Neueste Beiträge
Thanks Corné.. that was helpful.
thumbnail
Andew Jardine, geändert vor 12 Jahren.

RE: Translate portlet name

Liferay Legend Beiträge: 2416 Beitrittsdatum: 22.12.10 Neueste Beiträge
Hi Corné,

Maybe if I provide a better example emoticon. In my portlet.xml I have this --


	<portlet>
		<portlet-name>endeca-navigation</portlet-name>
		<display-name>Endeca Navigation Portlet</display-name>
                ...
       </portlet>o


I tried putting javax.portlet.title.endeca-navigation=... in both my Resources_en/fr and in a Languages_en/fr but in both cases the same title is showing. I followed the link that you posted on this thread and found this at the bottom --


Remember, if you have more than one portlet in your war, they won't be able to share the same resource bundle. What does this mean? It means you can't do this (as is done in the portal war):

javax.portlet.title.xxxx=TEST

You can only do:

javax.portlet.title=TEST
Use the method suggested above to separate your portlet resource bundles.


but I thought it was said here that Liferay supported the technique. If that is the case, am I specifying the values in the wrong place? Or am I missing something? This looks fairly straight forward to me, but it's not picking up.
thumbnail
Corné Aussems, geändert vor 12 Jahren.

RE: Translate portlet name

Liferay Legend Beiträge: 1313 Beitrittsdatum: 03.10.06 Neueste Beiträge
You should then define a different <resource-bundle>com.my.portlets.p1.Resource</resource-bundle> per Portlet
and use the normal JCR key javax.portlet.title.
thumbnail
Josef Šustáček, geändert vor 12 Jahren.

RE: Translate portlet name

New Member Beiträge: 22 Beitrittsdatum: 05.10.09 Neueste Beiträge
Hi,

if you need to localize several portlets' names, simply create separate .properties file for each of it, every with its own javax.portlet.title=XXX. The file can be emptry except this one line. Then the rest of localizaed messages could be shared, in some e.g. common.properties file.

In JSPs, you cant then load you localized messages from any file you want, just set it up to do so (using FMT, Spring taglib etc.). Using Spring, you even can define a MessageSource being composed from as many .properties files you want.

As someone already wrote before, you cannot localize names of more portlets in one .properties file via javax.portlet.title.<portlet_name>=XXX convention.
thumbnail
Andew Jardine, geändert vor 12 Jahren.

RE: Translate portlet name

Liferay Legend Beiträge: 2416 Beitrittsdatum: 22.12.10 Neueste Beiträge
Hi Josef,

I think I need to do exactly what you are suggesting, but I have never done this before. Can you point me to someplace where I can understand how to do this?
thumbnail
Josef Šustáček, geändert vor 12 Jahren.

RE: Translate portlet name

New Member Beiträge: 22 Beitrittsdatum: 05.10.09 Neueste Beiträge
Hi,

I'm not sure, what exactly you need to understand.

As I wrote before, create more .properties files, for every portlet one, and for every portlet, reference its file in portlet.xml in portlet's <resource-bundle />.

I assume, you ale localizing you messages (like button labels, fields labels, static texts in portlets) in your JSP files. You can load localized messages via two concepts (surely more, but these two are most commonly used):

  • FMT taglib from JSTL: http://codesnippets.joyent.com/posts/show/1151 -- beware and test the localization properly, when I used this approach the last time (LFR 5.2.3), currently selected portal language was not loaded correctly from portletRequest (i got messages localized in default locale, not the current one)
  • Spring MVC taglib from Spring framework: http://viralpatel.net/blogs/2010/07/spring-3-mvc-internationalization-i18n-localization-tutorial-example.html -- works simply and superb and lets you define more files, from which you can load localized message via one line of JSP code.
    • You only need to define you messageSource bean in context XML of your portlet, then it will automatically be loaded in you portlet JSPs. No need to define locale resolvers, it is all leveraged to portlal via Spring's implementaion of portlet MVC.


Hope its enough for you to start.
thumbnail
Jonas Fonseca, geändert vor 12 Jahren.

RE: Translate portlet name

New Member Beiträge: 11 Beitrittsdatum: 20.10.10 Neueste Beiträge
Andew Jardine:

but I thought it was said here that Liferay supported the technique. If that is the case, am I specifying the values in the wrong place? Or am I missing something? This looks fairly straight forward to me, but it's not picking up.

It is only supported for internal Liferay portlets. For portlets added via a plugin, you have to either specify the translated titles in portlet.xml or use separate resource bundles.

To make it easier to manage the resource bundle files in plugins with multiple portlets, I usually use ant to create the portlet-specific resource bundle files from a single resource bundle. I've described the technique here:

http://blog.priorarts.org/2011/11/getting-javaxportlettitleportletname-to.html