5
votes

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.

2
I've wrote my own liferay-hook to solve this issue. If someone is interested in the code, just leave a message.Robert Kornmesser
Is this about existing Liferay portlets or your own custom portlets?p.mesotten
This works on all portlets, because i hooked the look&feel modal windowRobert Kornmesser
Hi Robert, can you please share the code with me for this hook? I have a similar issue... Thanks!htmlr

2 Answers

2
votes

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

0
votes

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.