The easiest way to customize the
LocalePolicy
is to extend DefaultLocalePolicyService
. The study of its source parameter will be required. There is
sample JavaDoc that provides thorough information. Most customizations will involve simply overriding one or more
of its protected methods.
An example of a customization is NoBrowserLocalePolicyService
. By overriding
just one method, it skips any use of browser language preference.
public class NoBrowserLocalePolicyService extends DefaultLocalePolicyService
{
/**
* Override super method with no-op.
*
* @param context locale context info available to implementations in order to determine appropriate Locale
* @return null
*/
@Override
protected Locale getLocaleConfigFromBrowser(LocaleContextInfo context)
{
return null;
}
}