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
Modifier and TypeFieldDescriptionstatic final String
The configuration property for comma separated available languages.static final String
The configuration property forI18nContex
inheritance by child threads in per-thread based context providers.static final String
The configuration property forI18nContextProvider
implementation to use.static final String
The configuration property for default language.static final String
The configuration property for defaultI18nResources
bundle base name.static final String
The I18N configuration resource.static final String
The configuration properties prefix for namedI18nResources
bundle base name.static final String
The configuration properties prefix. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull Properties
get()
Returns the I18N configuration for the current class loader.static @NotNull Properties
get
(@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 forI18nContextProvider
implementation to use. TakesDEFAULT
by default.- See Also:
-
CONTEXT_INHERITED
The configuration property forI18nContex
inheritance by child threads in per-thread based context providers. Takestrue
by 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 defaultI18nResources
bundle base name. Takesmessages
by default.- See Also:
-
NAMED_RESOURCES_PREFIX
The configuration properties prefix for namedI18nResources
bundle base name.To be concatenated with bundle name. For example: "dev.orne.i18n.resources.named."
.alt-messages
configures 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:
-