组合视图 统一视图 树状图
讨论主题 [ 上一个 | 下一个 ]
toggle
Puj Z
reading from language bundle in a java file
2012年4月16日 上午1:08
答复

Puj Z

等级: Regular Member

帖子: 220

加入日期: 2010年1月14日

最近的帖子

Hi Community,

I am trying to read the translation of a key in a java class with this code (in my ModelLocalServiceImpl), but it is not returning the translation:
String translation = LanguageUtil.format(new Locale("fa_IR"), my-key,null);

Does anyone know what I am doing wrong? The bundle settings are ok, because I see the translation in jsps (by using liferay:ui-message)

Thanks for any helps in advance,
Puj
Siby Mathew
RE: reading from language bundle in a java file
2012年8月3日 上午8:46
答复

Siby Mathew

等级: Expert

帖子: 265

加入日期: 2011年3月4日

最近的帖子

Hi,
I have used the following code to retrieve the specific language value :
1final PortletConfig portletConfig = (PortletConfig) actionRequest
2                .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
3        // Return language file specific to the locale
4        return LanguageUtil.get(portletConfig, locale, key);