« Zurück zu Liferay Faces

Internationalizing JSF Portlets

There are at least two ways for handing internationalization with JSF and Liferay:

  1. Using the standard JSF mechanism to create your own i18n keyword, as shown in the jsf2-portlet demo.
  2. Using the built-in i18n keyword provided by the Liferay Faces Portal project, as shown in the jsf2-registration-portlet demo. I think this is a very nice integration point for JSF+Liferay, because it is able to "hook" into the thousands of existing internationalized keys that ship with Liferay Portal, as well as add your own. For more information on this approach, see the section titled "i18n" in the Liferay Faces documentation.
0 Anhänge
10868 Angesehen
Durchschnitt (0 Stimmen)
Die durchschnittliche Bewertung ist 0.0 von max. 5 Sternen.
Kommentare
Antworten im Thread Autor Datum
Will this allow JSF to look into the liferay... lucas theisen 29. Januar 2013 11:13
It appears the Liferay language hook (solution... lucas theisen 31. Januar 2013 07:54
Apologies Lucas -- although I authored the... Neil Griffin 4. Mai 2013 13:16
Hi Neil, right now i am using a combination of... lucas theisen 6. Mai 2013 08:13
Have you considered adding your "portlet... Neil Griffin 6. Mai 2013 08:33
Yes, however we have many other projects that... lucas theisen 6. Mai 2013 08:45
I'm pretty sure that you can have more than one... Neil Griffin 6. Mai 2013 09:25
Hi everyone, I used the standard mechanism to... J Viso 28. Januar 2014 04:29
You mention i18n.properties so I am assuming... Neil Griffin 28. Januar 2014 06:54
Hi Neil, Yes, I was using option #1. And I... J Viso 30. Januar 2014 09:18
I'm glad to hear that it is working in your... Neil Griffin 30. Januar 2014 09:27

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?
Gepostet am 29.01.13 11:13.
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?
Gepostet am 31.01.13 07:54.
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
Gepostet am 04.05.13 13:16 als Antwort auf 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?
Gepostet am 06.05.13 08:13 als Antwort auf 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
Gepostet am 06.05.13 08:33.
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?
Gepostet am 06.05.13 08:45 als Antwort auf Neil Griffin.
I'm pretty sure that you can have more than one Language hook per portal instance. I recommend giving it a try.
Gepostet am 06.05.13 09:25.
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.
Gepostet am 28.01.14 04:29.
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.
Gepostet am 28.01.14 06:54 als Antwort auf 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.
Gepostet am 30.01.14 09:18 als Antwort auf 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. :-)
Gepostet am 30.01.14 09:27 als Antwort auf J Viso.