掲示板

A possible bug with LanguageUtil

7年前 に Csaba Meszaros によって更新されました。

A possible bug with LanguageUtil

Junior Member 投稿: 42 参加年月日: 13/10/10 最新の投稿
I have Language.properties files in /resources/content, which are defined and visible on JSP pages. In a portlet class, however the following code doesn't seem to work:

String myValue=LanguageUtil.get(user.getLocale(),"my.key");

user.getLocale() is defined, the key exist, but it returns "my.key".

This is happening on LR 7.0 GA3, Linux.
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: A possible bug with LanguageUtil

Liferay Legend 投稿: 14915 参加年月日: 06/09/02 最新の投稿
When you get the key you pass in, that means that it cannot find a replacement value so you just get the key instead.

LanguageUtil does not check your local message bundles, it only pulls from the Liferay message bundles.
7年前 に Csaba Meszaros によって更新されました。

RE: A possible bug with LanguageUtil

Junior Member 投稿: 42 参加年月日: 13/10/10 最新の投稿
So what would be the correct way of obtaining the key value from portal's local Language.properties file.
Your answer would be much better if you'd give a working answer. Of course if it is not a top secret in Liferay Inc. emoticon
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: A possible bug with LanguageUtil

Liferay Legend 投稿: 14915 参加年月日: 06/09/02 最新の投稿
So normally we don't do backend language bundle handling, instead that is left to the front end.

For backend, you need to get access to your ResourceBundle, and typically you can get there from the PortletConfig object:

PortletConfig portletConfig = (PortletConfig)actionRequest.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
ResourceBundle rb = porteltConfig.getResourceBundle(userLocale);


Once you have the RB you can grab a localized string.
7年前 に Csaba Meszaros によって更新されました。

RE: A possible bug with LanguageUtil

Junior Member 投稿: 42 参加年月日: 13/10/10 最新の投稿
Thanks! This is what I was looking for. emoticon