I will make it short and simple
- Create the language bundle in src/content folder with files like Language.properties, Language_ar_SA.properties etc.
- For portlet api to use this bundle so that it can set the title etc as per the language selected, you need to set this bundle in portlet.xml file using
<resource-bundle>content.Language</resource-bundle>
- Then in bundle, you can set javax.portlet.title property for portlet to pick up based on the language selected.
- In jsps, for properties used in your use cases you can write the following:
<fmt:setLocale value="<%=themeDisplay.getLanguageId() %>"/>
<fmt:setBundle basename="content.Language" />
<h1><fmt:message key="profile.label"/></h1>
- In your portlet class you can do the following:
ThemeDisplay display = (ThemeDisplay) request
.getAttribute(WebKeys.THEME_DISPLAY)
System.out.println(display.getLanguageId());
ResourceBundle rb = ResourceBundle.getBundle("content.Language",
LocaleUtil.fromLanguageId(display.getLanguageId()));// LocaleUtil.fromLanguageId("ar"));
String label = rb.getString("profile.label");
System.out.println(label);
No comments:
Post a Comment