Hide or disable the portlet for specific languages ​​in the Liferay Portal

if there is a normal page with some portlets and a portlet of the change language. Can I hide specific portlets for specific languages? Maybe through prefrants from the portlet (only for these locales ...)?

Thanks in advance.

+4
source share
2 answers

you can use the if statement in your portlet and use the following code:

<%ThemeDisplay themeDisplay = new ThemeDisplay(); String langid=null; if(LanguageUtil.getLanguageId(request).equals("fa_IR")) { //display Farsi portlet } %> <%=langid%> 

or for a better result, you can use the switch statement

+1
source

I assume that you already know that you can change the available locales at the portal level with

 Portal Settings > Display > Available Languages 

or through the "locales" properties in portal.properties (http://www.liferay.com/community/wiki/-/wiki/Main/Languagedisplay+customization#section-Languagedisplay+customization-Removing+unwanted+language).

At the portlet level, I'm not sure how to do this with interceptors, but with the ext plugin you can try to override / extend getResourceBundle (Locale locale) in PortletConfigImpl and return your own XResourceBundle, which filters locales that override handleGetObject, getKeys (), getResourceBundle methods (), therefore, if the locale is not in the set, falback is returned.

0
source

Source: https://habr.com/ru/post/1392430/


All Articles