Visualização combinada Visão plana Exibição em árvore
Tópicos [ Anterior | Próximo ]
toggle
nathan c
Translate portlet name
21 de Julho de 2010 00:52
Resposta

nathan c

Ranking: New Member

Mensagens: 3

Data de entrada: 21 de Julho de 2010

Mensagens recentes

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 :

1
2<portlet-info>
3    <title>Title</title>
4    <short-title>title</short-title>
5    <keywords>title</keywords>
6</portlet-info>


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

Thanks in advance.
Alexandre Fiévée
RE: Translate portlet name
21 de Julho de 2010 01:06
Resposta

Alexandre Fiévée

Ranking: New Member

Mensagens: 23

Data de entrada: 24 de Outubro de 2008

Mensagens recentes

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 c
RE: Translate portlet name
21 de Julho de 2010 06:55
Resposta

nathan c

Ranking: New Member

Mensagens: 3

Data de entrada: 21 de Julho de 2010

Mensagens recentes

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...
Corné Aussems
RE: Translate portlet name
21 de Julho de 2010 07:01
Resposta

Corné Aussems

Ranking: Liferay Legend

Mensagens: 1270

Data de entrada: 3 de Outubro de 2006

Mensagens recentes

add this to your own portlets property files

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


and define it in portlet.xml
1<portlet>
2<resource-bundle>com.foo.Resource</resource-bundle></portlet>
nathan c
RE: Translate portlet name
21 de Julho de 2010 07:50
Resposta

nathan c

Ranking: New Member

Mensagens: 3

Data de entrada: 21 de Julho de 2010

Mensagens recentes

That's what I was looking for, translation is OK now.

Thank you.
Andew Jardine
RE: Translate portlet name
24 de Outubro de 2011 12:59
Resposta

Andew Jardine

Ranking: Expert

Mensagens: 260

Data de entrada: 22 de Dezembro de 2010

Mensagens recentes

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

1
2<portlet>       
3        <portlet-name>search</portlet-name>       
4        <display-name>Search Portlet</display-name>   
5                ...
6</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.
Corné Aussems
RE: Translate portlet name
24 de Outubro de 2011 13:21
Resposta

Corné Aussems

Ranking: Liferay Legend

Mensagens: 1270

Data de entrada: 3 de Outubro de 2006

Mensagens recentes

See this post for example and this one

Maybe it is because you use a forbidden word 'search' emoticon
Ravi Kumar Gupta
RE: Translate portlet name
24 de Outubro de 2011 21:23
Resposta

Ravi Kumar Gupta

Ranking: Liferay Legend

Mensagens: 1205

Data de entrada: 23 de Junho de 2009

Mensagens recentes

Hi Corné,

This is not for all standard portlet or is it? Will this work for Liferay only..??
1
2javax.portlet.title.portlet123=My Portlet


-Ravi
Corné Aussems
RE: Translate portlet name
25 de Outubro de 2011 01:09
Resposta

Corné Aussems

Ranking: Liferay Legend

Mensagens: 1270

Data de entrada: 3 de Outubro de 2006

Mensagens recentes

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..??
1
2javax.portlet.title.portlet123=My Portlet


-Ravi
Ravi Kumar Gupta
RE: Translate portlet name
30 de Outubro de 2011 23:47
Resposta

Ravi Kumar Gupta

Ranking: Liferay Legend

Mensagens: 1205

Data de entrada: 23 de Junho de 2009

Mensagens recentes

Thanks Corné.. that was helpful.
Andew Jardine
RE: Translate portlet name
21 de Novembro de 2011 07:01
Resposta

Andew Jardine

Ranking: Expert

Mensagens: 260

Data de entrada: 22 de Dezembro de 2010

Mensagens recentes

Hi Corné,

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

1
2    <portlet>
3        <portlet-name>endeca-navigation</portlet-name>
4        <display-name>Endeca Navigation Portlet</display-name>
5                ...
6       </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.
Corné Aussems
RE: Translate portlet name
21 de Novembro de 2011 07:24
Resposta

Corné Aussems

Ranking: Liferay Legend

Mensagens: 1270

Data de entrada: 3 de Outubro de 2006

Mensagens recentes

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.
Josef Šustáček
RE: Translate portlet name
21 de Novembro de 2011 07:27
Resposta

Josef Šustáček

Ranking: New Member

Mensagens: 22

Data de entrada: 5 de Outubro de 2009

Mensagens recentes

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.
Jonas Fonseca
RE: Translate portlet name
21 de Novembro de 2011 07:40
Resposta

Jonas Fonseca

Ranking: New Member

Mensagens: 12

Data de entrada: 20 de Outubro de 2010

Mensagens recentes

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
Andew Jardine
RE: Translate portlet name
21 de Novembro de 2011 07:44
Resposta

Andew Jardine

Ranking: Expert

Mensagens: 260

Data de entrada: 22 de Dezembro de 2010

Mensagens recentes

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?
Josef Šustáček
RE: Translate portlet name
21 de Novembro de 2011 08:02
Resposta

Josef Šustáček

Ranking: New Member

Mensagens: 22

Data de entrada: 5 de Outubro de 2009

Mensagens recentes

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):

  1. 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)
  2. 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.