« 返回到 Liferay Faces

Internationalizing JSF Portlets

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

0 附件
33572 查看
平均 (0 票)
满分为 5,平均得分为 0.0。
评论
讨论主题回复 作者 日期
Will this allow JSF to look into the liferay... lucas theisen 2013年1月29日 上午11:13
It appears the Liferay language hook (solution... lucas theisen 2013年1月31日 上午7:54
Apologies Lucas -- although I authored the... Neil Griffin 2013年5月4日 下午1:16
Hi Neil, right now i am using a combination of... lucas theisen 2013年5月6日 上午8:13
Have you considered adding your "portlet... Neil Griffin 2013年5月6日 上午8:33
Yes, however we have many other projects that... lucas theisen 2013年5月6日 上午8:45
I'm pretty sure that you can have more than one... Neil Griffin 2013年5月6日 上午9:25
Hi everyone, I used the standard mechanism to... J Viso 2014年1月28日 上午4:29
You mention i18n.properties so I am assuming... Neil Griffin 2014年1月28日 上午6:54
Hi Neil, Yes, I was using option #1. And I... J Viso 2014年1月30日 上午9:18
I'm glad to hear that it is working in your... Neil Griffin 2014年1月30日 上午9:27
It would be nice to add how to find the... Natalio Sacerdote 2014年11月7日 上午1:23

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?
在 13-1-29 上午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?
在 13-1-31 上午7: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
在 13-5-4 下午1:16 发帖以回复 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?
在 13-5-6 上午8:13 发帖以回复 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
在 13-5-6 上午8: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?
在 13-5-6 上午8:45 发帖以回复 Neil Griffin
I'm pretty sure that you can have more than one Language hook per portal instance. I recommend giving it a try.
在 13-5-6 上午9: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.
在 14-1-28 上午4: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.
在 14-1-28 上午6:54 发帖以回复 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.
在 14-1-30 上午9:18 发帖以回复 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. :-)
在 14-1-30 上午9:27 发帖以回复 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".
在 14-11-7 上午1:23 发帖。