Resource Bundle Override

This example overrides the default javax.portlet.title.com_liferay_login_web_portlet_LoginPortlet language key for Liferay DXP’s default Login portlet. After deploying this sample to Liferay DXP, the Login portlet’s Sign In title is modified to display Login Portlet Override.

Figure 1: The customized Login portlet displays the new language key.

Figure 1: The customized Login portlet displays the new language key.

For reference, the Login portlet’s language keys are stored in the liferay-portal Github repo’s modules/apps/login/login-web/src/main/resources/content folder.

What API(s) and/or code components does this sample highlight?

This sample leverages the Provide-Capability OSGi manifest header.

How does this sample leverage the API(s) and/or code component?

This sample conveys the recommended approach to override a portlet’s language keys file for any module that is deployed to Liferay DXP’s OSGi runtime (not applicable to Liferay DXP’s core language keys).

The steps to override a portlet’s language keys are

  • Provide the new language keys that will override the original ones.
  • Prioritize the new module’s resource bundle.

This sample’s src/main/resources/content folder holds the language properties file to override. Since this example’s goal is to override only the English keys, the is added. You can add more language properties files for additional language key locales you want to override (e.g., for Spanish).

Once your language keys are in place, you must use OSGi manifest headers to specify your custom language keys are for the target module. To compliment the target module’s resource bundle, you must aggregate your resource bundle with the target module’s resource bundle. This is done by ranking your module first to prioritize its resource bundle over the target module resource bundle. See this sample’s bnd.bnd as an example for setting the Provide-Capability OSGi header:


For more information on the Provide-Capability header and its parts, see the Prioritze Your Module’s Resource Bundle section.

This approach can be used to override any portlet’s language keys (i.e., files that are inside a module deployed to Liferay DXP’s OSGi runtime). If you need to override Liferay DXP’s core language keys, see the Overriding Global Language Keys article.

For more information on using a resource bundle to override a module’s language keys, see the Overriding a Module’s Language Keys tutorial.

Where Is This Sample?

There are three different versions of this sample, each built with a different build tool:

« Module JSP OverrideThemes »
Was this article helpful?
0 out of 0 found this helpful