Wednesday 29 February 2012

How to get message resources in portlet

It is not something special just some note for myself :)


You can get message properties next way:

1) Into Java code:
String someText = LanguageUtil.get(actionRequest.getLocale(), "some-text");
2) Into Java code:
ResourceBundle myResources = ResourceBundle.getBundle("content/Language", actionRequest.getLocale());
String someText = myResources.getString("some-text");
3) At JSP page:


3) At Javascript:
Liferay.Language.get("your-language-key")

BR,
Paul

1 comment:

  1. 2) If you use non-english resource you must write like this:
    new String(myResources.getString("some-text").getBytes(StringPool.ISO_8859_1))

    ReplyDelete