@Target(value={METHOD,FIELD,PARAMETER}) @Retention(value=RUNTIME) @InjectAnnotation public @interface I18N
I18n
object or a
particular internationalized string. Internationalization depends on the detection of the locale.
By default, the locale is detected through the property of the current resource page. To override this, one can either provide a particular locale value, a locale detector (a routine that guesses on the locale by, e.g., the request path) or fall back to the standard mechanism which guesses on a locale by the preferences of the current user.
The preferred adaptable object for this injector in an AEM environment is SlingHttpServletRequest
. If
adaptation is done from a Resource
, the result depends on whether a proper Sling resource bundle exists for
the current installation
The type of the underlying Java member must be I18n
or else String
or Object
. Into object-typed members, a string is injected
Modifier and Type | Optional Element and Description |
---|---|
String |
locale
Used to specify the locale in one of the formats like
en , en/us , en-us , or en_US . |
Class<? extends Function<Object,Locale>> |
localeDetector
Used to specify a routine that will be used for detecting the current locale unless a particular value is set up
via
locale() . |
String |
value
Used to specify the string value to internationalize.
|
public abstract String locale
en
, en/us
, en-us
, or en_US
.
One can provide either a two-symbol language token or a language-country pair (note: language must come first).
If this parameter is specified it overrides the localeDetector()
property. If neither
locale
nor localeDetector
are set, the locale is guessed based on the current resource page
public abstract Class<? extends Function<Object,Locale>> localeDetector
locale()
. A locale detector must implement the Function<Object, Locale>
interface.
It is invoked with the call to the interface's Function.apply(Object)
method.
By default, the PageLocaleDetector
is turned on. It detects the locale based on the current resource
page property. To bring back the AEM's default behavior (detection based on the authenticated user's properties),
specify NativeLocaleDetector
Class
referencepublic abstract String value
String
or Object
Copyright © 2024 Exadel, Inc.. All rights reserved.