Localizing JSF Portlets

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:

  1. 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 sample liferay-hook.xml file that hooks into a Liferay Portal language properties file can be found in the jsf-registration-portlet here.

  2. 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.

  3. 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 variable new-user-registration, the declaration would look like this:

     <alloy:form id="f">
         <h1 class="header-title">#{i18n['new-user-registration']}</h1>

    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.

Liferay Faces Alloy UI Components

Liferay Faces Bridge UI Components

Understanding Liferay Faces Bridge

Understanding Liferay Faces Portal

Understanding Liferay Faces Alloy

« Accessing the Portlet API with ExternalContext for JSF PortletsCommunicating Between JSF Portlets Using IPC »
Este artigo foi útil?
Utilizadores que acharam útil: 0 de 0