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
Constructors -
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.voidsetContexts(List<ContextContribution> contexts) voidsetSystemLocale(Locale systemLocale) Gets the system locale.ch.tocco.nice2.textresources.impl.i18n.L10NImpl.InvokerReturns anInvokerthat can be used to invoke code changing the context.ch.tocco.nice2.textresources.impl.i18n.L10NImpl.InvokerReturns anInvokerthat can be used to invoke code using the specified locale.ch.tocco.nice2.textresources.impl.i18n.L10NImpl.InvokerReturns anInvokerthat 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:L10NGets 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:
systemLocalein interfaceL10N- Returns:
- The system locale.
-
fallbackLocale
Description copied from interface:L10NGets the fallback locale for the thread's current context.- Specified by:
fallbackLocalein interfaceL10N- Returns:
- The fallback locale.
-
fallbackLocale
Description copied from interface:L10NGets the fallback locale for the specified context.- Specified by:
fallbackLocalein interfaceL10N- Parameters:
contextName- The context or `null` for the current context.- Returns:
- The fallback locale.
-
availableLocales
Description copied from interface:L10NGets the available locales for the thread's current context ordered by their preference.- Specified by:
availableLocalesin interfaceL10N- Returns:
- A
Setof all available locales.
-
availableLocales
Description copied from interface:L10NGets the available locales for the specified context ordered by their preference.- Specified by:
availableLocalesin interfaceL10N- Parameters:
contextName- The context or `null` for the current context.- Returns:
- A
Setof all available locales or an empty list, if no such context has been defined.
-
availableContexts
Description copied from interface:L10NGets the available contexts.- Specified by:
availableContextsin interfaceL10N- Returns:
- A
Setof available contexts.
-
currentLocale
Description copied from interface:L10NGets the current locale. This is the locale that has been set by invoking code through theInvokerspecified inContext.using().- Specified by:
currentLocalein interfaceL10N- Returns:
- The current locale.
- See Also:
-
currentContext
Description copied from interface:L10NGets the current context.- Specified by:
currentContextin interfaceL10N- Returns:
- The current context.
-
bestLocaleFor
Description copied from interface:L10NGets the best available locale for the specified list of requested locales based on the thread's current context.- Specified by:
bestLocaleForin interfaceL10N- Parameters:
requested- The list of preferred locales.- Returns:
- The best available locale for the requested locale.
- See Also:
-
bestLocaleFor
Description copied from interface:L10NGets 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:
bestLocaleForin 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:L10NReturns anInvokerthat 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:L10NReturns anInvokerthat can be used to invoke code changing the context and locale. -
using
Description copied from interface:L10NReturns anInvokerthat can be used to invoke code changing the context.
-