In this tutorial, you’ll learn how to internationalize your JSF portlet. If you’re unfamiliar with the term localization, you can learn the basics about it here.
The recommended way to handle internationalization with JSF portlets is demonstrated in the jsf-registration-portlet demo. This method integrates JSF and Liferay seamlessly because it lets you hook into thousands of existing internationalized keys that Liferay Portal includes, and allows you to add your own keys. The following steps demonstrate how to do this:
-
Create a language properties hook inside your portlet plugin and make sure to add a
language-properties
element for each locale that your portlet supports. A sampleliferay-hook.xml
file that hooks into a Liferay Portal language properties file can be found in the jsf-registration-portlet here. -
Create internationalized Language properties files for each locale and add your key/value pairs to them. You can view a sample
Language_en_US.properties
here. -
Use the built-in i18n keyword Expression Language (EL) in your Facelet view. For example, for an
<alloy:form> element
declaring the header title as the variablenew-user-registration
, the declaration would look like this:<alloy:form id="f"> <h1 class="header-title">#{i18n['new-user-registration']}</h1> ... </alloy:form>
As an example of using the built-in i18n keyword, you can refer to example XHTML file
registrant.xhtml
from the demonstration portlet jsf-registration-portlet.
Internationalizing your portlets is especially easy to do using the options that Liferay Faces provides. Awesome! You now know how to internationalize your JSF portlet.
Related Topics
Liferay Faces Alloy UI Components
Liferay Faces Bridge UI Components
Understanding Liferay Faces Bridge