Class I18nConfiguration

java.lang.Object
dev.orne.i18n.context.I18nConfiguration

@API(status=STABLE, since="0.1") public final class I18nConfiguration extends Object
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 Details

    • FILE

      public static final String FILE
      The I18N configuration resource.
      See Also:
    • PREFIX

      public static final String PREFIX
      The configuration properties prefix.
      See Also:
    • CONTEXT_PROVIDER

      public static final String CONTEXT_PROVIDER
      The configuration property for I18nContextProvider implementation to use. Takes DEFAULT by default.
      See Also:
    • CONTEXT_INHERITED

      public static final String CONTEXT_INHERITED
      The configuration property for I18nContex inheritance by child threads in per-thread based context providers. Takes true by default.
      See Also:
    • DEFAULT_LANGUAGE

      public static final String DEFAULT_LANGUAGE
      The configuration property for default language. Takes Locale.getDefault() by default.
      See Also:
    • AVAILABLE_LANGUAGES

      public static final String AVAILABLE_LANGUAGES
      The configuration property for comma separated available languages. Takes Locale.getAvailableLocales() by default.
      See Also:
    • DEFAULT_RESOURCES

      public static final String DEFAULT_RESOURCES
      The configuration property for default I18nResources bundle base name. Takes messages by default.
      See Also:
    • NAMED_RESOURCES_PREFIX

      public static final String NAMED_RESOURCES_PREFIX
      The configuration properties prefix for named I18nResources bundle base name.

      To be concatenated with bundle name. For example: "dev.orne.i18n.resources.named.".alt-messages configures resource with name alt-messages.

      See Also:
  • Method Details

    • get

      @API(status=EXPERIMENTAL, since="0.1") @NotNull public static @NotNull Properties 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: