Liferay is a Gartner Magic Quadrant Leader for the Sixth Year! Find out why
« Back to Liferay Faces

Internationalizing JSF Portlets

This article has been incorporated into the official Liferay documentation. Refer to the section titled Localizing JSF Portlets.

0 Attachments
28615 Views
Average (0 Votes)
The average rating is 0.0 stars out of 5.
Comments
Threaded Replies Author Date
Will this allow JSF to look into the liferay... lucas theisen January 29, 2013 11:13 AM
It appears the Liferay language hook (solution... lucas theisen January 31, 2013 7:54 AM
Apologies Lucas -- although I authored the... Neil Griffin May 4, 2013 1:16 PM
Hi Neil, right now i am using a combination of... lucas theisen May 6, 2013 8:13 AM
Have you considered adding your "portlet... Neil Griffin May 6, 2013 8:33 AM
Yes, however we have many other projects that... lucas theisen May 6, 2013 8:45 AM
I'm pretty sure that you can have more than one... Neil Griffin May 6, 2013 9:25 AM
Hi everyone, I used the standard mechanism to... J Viso January 28, 2014 4:29 AM
You mention i18n.properties so I am assuming... Neil Griffin January 28, 2014 6:54 AM
Hi Neil, Yes, I was using option #1. And I... J Viso January 30, 2014 9:18 AM
I'm glad to hear that it is working in your... Neil Griffin January 30, 2014 9:27 AM
It would be nice to add how to find the... Natalio Sacerdote November 7, 2014 1:23 AM

Will this allow JSF to look into the liferay Language_en_US.properties file for its validator messages? More to the point, if i add my message overrides in my company wide Language_en_us.properties, will the JSF framework find them there?
Posted on 1/29/13 11:13 AM.
It appears the Liferay language hook (solution 2 above) only works from a single portlet. If I have multiple portlets that each have their own Language.properties file what should I do? I am thinking the best way to handle is either use liferayfaces i18n for Liferay built-in messages and solution 1 above with portletI18n for the resource bundle var to get portlet specific messages. Is there a better way? Is it possible to configure the liferayfaces i18n to pull messages from a portlet specific resource bundle first then the Liferay built-in if the message was not found?
Posted on 1/31/13 7:54 AM.
Apologies Lucas -- although I authored the article, somehow I wasn't subscribed to this Wiki and didn't get alerted. Do you still need answers to these questions? -- Neil
Posted on 5/4/13 1:16 PM in reply to lucas theisen.
Hi Neil, right now i am using a combination of the 2approaches in the same project. I use i18n for liferay messages and pi18n (approach 1 above) to get portlet specific messages. This has a downside that it causes failures if the message doesnt exist (which liferay i18n seems to get around by returning the key itself if no message was found). It would be nice if the liferay i18n object could be configured with a portlet resource that it checks first and if the requested message is not found it passes it along to the liferay i18n. Best of both worlds approach. But I guess that makes this more of a feature request... What do you think? Is there a better way?
Posted on 5/6/13 8:13 AM in reply to Neil Griffin.
Have you considered adding your "portlet specific messages" via approach #2 using the hook? That's what we do in the jsf2-registration-portlet:
https://github.com/liferay/liferay-faces/blob/3.1.x/de­mos/portal/jsf2-registration-portlet/src/main/resources/Language_en_US.propertie­s
Posted on 5/6/13 8:33 AM.
Yes, however we have many other projects that all have their own messages. I was under the understanding that there can be only one language hook per liferay instance. Is that incorrect?
Posted on 5/6/13 8:45 AM in reply to Neil Griffin.
I'm pretty sure that you can have more than one Language hook per portal instance. I recommend giving it a try.
Posted on 5/6/13 9:25 AM.
Hi everyone,

I used the standard mechanism to internationalize my jsf portlet. It's working on Windows (Win7) but not in Linux (Fedora19).

Using exactly the same JBoss EAP 6.1 on Win7, when I change the language using the flags selector portlet, the text on the portlet change according the current culture, but not when JBoss is running on Fedora19.

On Fedora19, Liferay only translates the strings translated by the Liferay core, but doesn't translate the string I've localized on my i18n .properties files.

Do I have to do some extra work on Linux/Fedora?
What can I do to check if something is wrong?

Please tell me if you need any information or file to see what's the problem.

I appreciate your help, thanks in advance.
Posted on 1/28/14 4:29 AM.
You mention i18n.properties so I am assuming that you are using option#1 from the wiki article. Please try option#2 with the liferay-hook.xml and see if it works better.
Posted on 1/28/14 6:54 AM in reply to J Viso.
Hi Neil,

Yes, I was using option #1. And I tested it with the jsf2-portlet demo, and the result is the same: working on Windows7, not working on Fedora19.

As you suggested, I tried the option #2. And it works, with my project and with the jsf2-registration-portlet demo. And in both systems Win&Linux.

So, maybe there's a problem with the option #1 in some enviroments...

Let me point up also something about .properties language files. With the option #1 these files must have the ISO-8859-1 enconding, and the non ASCII characters escaped to unicode, to see them correctly on Liferay. But using the option #2, these files have to be UTF-8 encoded.

Anyway, the problem is solved, so thanks a lot.
Posted on 1/30/14 9:18 AM in reply to Neil Griffin.
I'm glad to hear that it is working in your environment now. And thanks for the helpful information about ISO-8859-1 encoding with option #1. :-)
Posted on 1/30/14 9:27 AM in reply to J Viso.
Natalio Sacerdote
It would be nice to add how to find the "thousands of existing internationalized keys that ship with Liferay Portal".
I was able to find them by extracting the contents of:
"tomcat-directory\webapps\ROOT\WEB-INF\lib\portal-impl.jar"
Then looking for file with name "Language_en.properties".
Posted on 11/7/14 1:23 AM.