public interface LocaleResolver
Locale resolvers are used to determine the locale of the current request and are discovered using CDI.
The MVC implementation is required to resolve the locale for each request following this algorithm:
Priority
to indicate their priority. If no
priority is explicitly defined, the priority is assumed to be 1000
.resolveLocale(LocaleResolverContext)
. If the resolver returns
a valid locale, use this locale as the request locale. If the resolver returns
null
, proceed with the next resolver in the ordered set.Controllers, view engines and other components can access the resolved locale by calling
MvcContext.getLocale()
.
The MVC implementation is required to provide a default locale resolver with a priority
of 0
which uses the Accept-Language
request header to obtain the
locale. If resolving the locale this way isn't possible, the default resolver must return
Locale.getDefault()
.
LocaleResolverContext
,
MvcContext.getLocale()
,
Locale
Modifier and Type | Method and Description |
---|---|
Locale |
resolveLocale(LocaleResolverContext context)
Resolve the locale of the current request given a
LocaleResolverContext . |
Locale resolveLocale(LocaleResolverContext context)
Resolve the locale of the current request given a LocaleResolverContext
.
If the implementation is able to resolve the locale for the request, the corresponding
locale must be returned. If the implementation cannot resolve the locale, it must return
null
. In this case the resolving process will continue with the next
resolver.
context
- the context needed for processing.null
.Copyright © 2019 Ivar Grimstad. All rights reserved.