Portlet language ResourceBundle usage

Ervinas Marocka, modified 6 Years ago. Junior Member Posts: 31 Join Date: 10/8/18 Recent Posts

Hello, I have a WAR file with many portlets inside (migrated from older Liferay version) and I want to use a different translation file for each of the portlets but it does not seem to work in Liferay 7.0 CE GA7. I have indicated <supported-locale> and <resource-bundle> tags in portlet.xml file, however, only one of the portlets is translated when using <liferay-ui:message> tags. The keys are displayed for the other portlets. I have tried to debug the code and found out that com.liferay.taglib.util.TagResourceBundleUtil class loads the same ResourceBundle for all portlets. It seems that it picks up the first OSGi ResourceBundleLoader service of the bundle. I have listed the ResourceBundleLoader services in Felix Gogo shell using this command: services | grep 'servlet.context.name=my-portlets, resource.bundle.base.name'.

 

If I assign 'null' to 'resourceBundleLoader' variable in the code snippet below from the TagResourceBundleUtil class using a debugger, the keys are translated. Am I missing something or is there a bug? I am just starting to use Liferay.

...

public static ResourceBundle getResourceBundle(

HttpServletRequest request, Locale locale) {

 

ResourceBundleLoader resourceBundleLoader = getResourceBundleLoader(

request); //Gets the first ResourceBundleLoader of the bundle. If I assign it to 'null' using a debugger, the keys are translated.

 

if (resourceBundleLoader != null) {

return resourceBundleLoader.loadResourceBundle(locale);

}

 

ResourceBundle portletResourceBundle = getPortletResourceBundle(

request, locale);