Robert Kornmesser
Robert Kornmesser

Reputation: 309

Hide or disable Portlet for specfic languages in Liferay Portal

given there is a normal page with some portlets and the change language portlet. Is it possible to hide specific portlets for specific languages? Maybe via Portlet prefrences (only show for these locales....)?

Thanks in advance.

Upvotes: 5

Views: 1744

Answers (2)

Whimusical
Whimusical

Reputation: 6629

I assume you already know you can change available locales at portal level from

Portal Settings > Display > Available Languages 

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

At portlet level, I am not sure how to do it with hooks, but with an ext plugin you could try to override/extend getResourceBundle(Locale locale) in PortletConfigImpl and return your own XResourceBundle which filters locales overriding methods handleGetObject, getKeys() , getResourceBundle(), so if a locale is not in the set, a falback one is returned.

Upvotes: 0

user1313720
user1313720

Reputation: 21

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

<%ThemeDisplay themeDisplay = new ThemeDisplay();

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

or for better result you can use a switch statement

Upvotes: 2

Related Questions