Class L10NImpl
java.lang.Object
ch.tocco.nice2.textresources.impl.i18n.L10NImpl
- All Implemented Interfaces:
L10N
-
Nested Class Summary
Nested classes/interfaces inherited from interface ch.tocco.nice2.textresources.api.i18n.L10N
L10N.Context
-
Field Summary
Fields inherited from interface ch.tocco.nice2.textresources.api.i18n.L10N
APPLICATION_CONTEXT, RENDERING_CONTEXT, SYSTEM_CONTEXT, WEB_CONTEXT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGets the available contexts.Gets the available locales for the thread's current context ordered by their preference.availableLocales
(@Nullable String contextName) Gets the available locales for the specified context ordered by their preference.bestLocaleFor
(List<Locale> requested) Gets the best available locale for the specified list of requested locales based on the thread's current context.bestLocaleFor
(List<Locale> requested, @Nullable String contextName) Gets the best *available* locale for the specified list of requested locales in the current context.Gets the current context.Gets the current locale.Gets the fallback locale for the thread's current context.fallbackLocale
(@Nullable String contextName) Gets the fallback locale for the specified context.void
setContexts
(List<ContextContribution> contexts) void
setSystemLocale
(Locale systemLocale) Gets the system locale.ch.tocco.nice2.textresources.impl.i18n.L10NImpl.Invoker
Returns anInvoker
that can be used to invoke code changing the context.ch.tocco.nice2.textresources.impl.i18n.L10NImpl.Invoker
Returns anInvoker
that can be used to invoke code using the specified locale.ch.tocco.nice2.textresources.impl.i18n.L10NImpl.Invoker
Returns anInvoker
that can be used to invoke code changing the context and locale.
-
Constructor Details
-
L10NImpl
public L10NImpl(org.slf4j.Logger log)
-
-
Method Details
-
setContexts
-
setSystemLocale
-
systemLocale
Description copied from interface:L10N
Gets the system locale. The system locale is the one used for all system tasks, that are basically *not* localised. The system locale is usually `en`.- Specified by:
systemLocale
in interfaceL10N
- Returns:
- The system locale.
-
fallbackLocale
Description copied from interface:L10N
Gets the fallback locale for the thread's current context.- Specified by:
fallbackLocale
in interfaceL10N
- Returns:
- The fallback locale.
-
fallbackLocale
Description copied from interface:L10N
Gets the fallback locale for the specified context.- Specified by:
fallbackLocale
in interfaceL10N
- Parameters:
contextName
- The context or `null` for the current context.- Returns:
- The fallback locale.
-
availableLocales
Description copied from interface:L10N
Gets the available locales for the thread's current context ordered by their preference.- Specified by:
availableLocales
in interfaceL10N
- Returns:
- A
Set
of all available locales.
-
availableLocales
Description copied from interface:L10N
Gets the available locales for the specified context ordered by their preference.- Specified by:
availableLocales
in interfaceL10N
- Parameters:
contextName
- The context or `null` for the current context.- Returns:
- A
Set
of all available locales or an empty list, if no such context has been defined.
-
availableContexts
Description copied from interface:L10N
Gets the available contexts.- Specified by:
availableContexts
in interfaceL10N
- Returns:
- A
Set
of available contexts.
-
currentLocale
Description copied from interface:L10N
Gets the current locale. This is the locale that has been set by invoking code through theInvoker
specified inContext.using()
.- Specified by:
currentLocale
in interfaceL10N
- Returns:
- The current locale.
- See Also:
-
currentContext
Description copied from interface:L10N
Gets the current context.- Specified by:
currentContext
in interfaceL10N
- Returns:
- The current context.
-
bestLocaleFor
Description copied from interface:L10N
Gets the best available locale for the specified list of requested locales based on the thread's current context.- Specified by:
bestLocaleFor
in interfaceL10N
- Parameters:
requested
- The list of preferred locales.- Returns:
- The best available locale for the requested locale.
- See Also:
-
bestLocaleFor
Description copied from interface:L10N
Gets the best *available* locale for the specified list of requested locales in the current context. The locale list should be sorted by preference, the most preferred locale first. Returns the fallback locale if no suitable locale is available.- Specified by:
bestLocaleFor
in interfaceL10N
- Parameters:
requested
- The list of preferred locales.contextName
- The context or `null` for the current context.- Returns:
- The best available locale for the requested locale.
- See Also:
-
using
Description copied from interface:L10N
Returns anInvoker
that can be used to invoke code using the specified locale. -
using
public ch.tocco.nice2.textresources.impl.i18n.L10NImpl.Invoker using(Locale locale, String contextName) Description copied from interface:L10N
Returns anInvoker
that can be used to invoke code changing the context and locale. -
using
Description copied from interface:L10N
Returns anInvoker
that can be used to invoke code changing the context.
-