eXo Platform 4.0 Documentation > Reference Guide / GateIn > Portal Development > Pluggable locale policy

2.8.1. LocalePolicy API

Customization is achieved by using LocalePolicy API, which is a simple API consisting of one interface, and one class:

The LocalePolicy interface defines a single method that is invoked on the installed LocalePolicy service implementation:

public interface LocalePolicy
{
   public Locale determineLocale(LocaleContextInfo localeContext);
}
         

Locale returned by the determineLocale() method is Locale that will be returned to portlets when they call the javax.portlet.PortletRequest.getLocale() method.

The returned Locale has to be one of the locales supported by the portal, otherwise it will fallback to portal-default Locale.

The supported locales are listed in the gatein.ear/portal.war/WEB-INF/conf/common/locales-config.xml file as described in Locales configuration.

The determineLocale() method takes a parameter of the LocaleContextInfo type, which represents a compilation of preferred locales from different sources, including users' profile, portal default, browser language settings, current session, browser cookie, and more. All these different sources of the Locale configuration or preference are used as input to the LocalePolicy implementation that decides which Locale should be used.

Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus