Package dev.orne.i18n.context
Class I18nConfiguration
java.lang.Object
dev.orne.i18n.context.I18nConfiguration
Utility class with I18N configuration constants and retrieval methods.
Configuration is loaded from application provided "dev.orne.i18n.config.properties" properties file. Only one configuration file is allowed by class loader.
- Since:
- 0.1
- Version:
- 1.0, 2023-11
- Author:
- (w) Iker Hernaez
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe configuration property for comma separated available languages.static final StringThe configuration property forI18nContexinheritance by child threads in per-thread based context providers.static final StringThe configuration property forI18nContextProviderimplementation to use.static final StringThe configuration property for default language.static final StringThe configuration property for defaultI18nResourcesbundle base name.static final StringThe I18N configuration resource.static final StringThe configuration properties prefix for namedI18nResourcesbundle base name.static final StringThe configuration properties prefix. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull Propertiesget()Returns the I18N configuration for the current class loader.static @NotNull Propertiesget(@NotNull ClassLoader cl) Returns the I18N configuration for the specified class loader.
-
Field Details
-
FILE
The I18N configuration resource.- See Also:
-
PREFIX
The configuration properties prefix.- See Also:
-
CONTEXT_PROVIDER
The configuration property forI18nContextProviderimplementation to use. TakesDEFAULTby default.- See Also:
-
CONTEXT_INHERITED
The configuration property forI18nContexinheritance by child threads in per-thread based context providers. Takestrueby default.- See Also:
-
DEFAULT_LANGUAGE
The configuration property for default language. TakesLocale.getDefault()by default.- See Also:
-
AVAILABLE_LANGUAGES
The configuration property for comma separated available languages. TakesLocale.getAvailableLocales()by default.- See Also:
-
DEFAULT_RESOURCES
The configuration property for defaultI18nResourcesbundle base name. Takesmessagesby default.- See Also:
-
NAMED_RESOURCES_PREFIX
The configuration properties prefix for namedI18nResourcesbundle base name.To be concatenated with bundle name. For example: "dev.orne.i18n.resources.named."
.alt-messagesconfigures resource with namealt-messages.- See Also:
-
-
Method Details
-
get
Returns the I18N configuration for the current class loader.- Returns:
- The I18N configuration properties
- Throws:
I18nConfigurationException- If an error occurs loading the configuration.- See Also:
-
get
@API(status=EXPERIMENTAL, since="0.1") @NotNull public static @NotNull Properties get(@NotNull @NotNull ClassLoader cl) Returns the I18N configuration for the specified class loader. If the class loader has a "dev.orne.i18n.config.properties" resource loads the configuration from the file. Otherwise inherits the configuration from the parent class loader and, if none has a custom configuration, applies the default configuration.Note that having more that one "dev.orne.i18n.config.properties" in a class loader throws a
I18nConfigurationException.- Parameters:
cl- The class loader to retrieve the configuration for.- Returns:
- The configuration properties.
- Throws:
I18nConfigurationException- If an error occurs loading the configuration.- See Also:
-