Package com.oorian.i18n
Class AcceptLanguageLocaleResolver
java.lang.Object
com.oorian.i18n.AcceptLanguageLocaleResolver
- All Implemented Interfaces:
LocaleResolver
Resolves the locale from the browser's
Accept-Language HTTP header.
This is the simplest resolver and the default used by LocaleConfiguration.
It delegates to OorianHttpRequest.getLocale(), which returns the preferred
locale from the browser's Accept-Language header.
Usage:
// Standalone (this is the default resolver)
LocaleConfiguration.setLocaleResolver(new AcceptLanguageLocaleResolver());
- Since:
- 2.1
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new resolver that uses the browser's Accept-Language header. -
Method Summary
Modifier and TypeMethodDescriptionresolveLocale(OorianHttpRequest request) Resolves the locale from the request's Accept-Language header.
-
Constructor Details
-
AcceptLanguageLocaleResolver
public AcceptLanguageLocaleResolver()Creates a new resolver that uses the browser's Accept-Language header.
-
-
Method Details
-
resolveLocale
Resolves the locale from the request's Accept-Language header.Delegates to
OorianHttpRequest.getLocale(), which returns the preferred locale as determined by the servlet container from the Accept-Language header. This method always returns a non-null value.- Specified by:
resolveLocalein interfaceLocaleResolver- Parameters:
request- the current HTTP request- Returns:
- the preferred locale from the Accept-Language header
-