Package dev.orne.i18n

Interface I18nResources

All Known Implementing Classes:
DummyI18nResources, I18nBundleResources, I18nSpringResources

@API(status=STABLE, since="0.1") public interface I18nResources
Interface for I18N messages source. Provides an implementation agnostic way to retrieve I18N messages based in the current I18nContext locale.

The default messages are expect to be MessageFormat compliant.

Since:
0.1
Version:
1.0, 2021-01
Author:
(w) Iker Hernaez
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull String
    getMessage(@NotNull String defaultMessage, @NotNull String[] codes, @NotNull Locale locale, Object... params)
    Retrieves the I18N message for the specified locale of the first message code efined in this I18N resources of specified message codes.
    default @NotNull String
    getMessage(@NotNull String defaultMessage, @NotNull String[] codes, Object... params)
    Retrieves the I18N message for the specified locale of the first message code efined in this I18N resources of specified message codes.
    @NotNull String
    getMessage(@NotNull String defaultMessage, @NotNull String code, @NotNull Locale locale, Object... params)
    Retrieves the I18N message for the specified message code and locale.
    default @NotNull String
    getMessage(@NotNull String defaultMessage, @NotNull String code, Object... params)
    Retrieves the I18N message for the specified message code and the 18N context locale.
  • Method Details

    • getMessage

      @NotNull default @NotNull String getMessage(@NotNull @NotNull String defaultMessage, @NotNull @NotNull String code, Object... params)
      Retrieves the I18N message for the specified message code and the 18N context locale. If the message code is not defined in this I18N resources the specified default message is used. The message is formatted with the provided parameters.
      Parameters:
      defaultMessage - The default message format
      code - The message code
      params - The message parameters
      Returns:
      The formatted message in the I18N context locale
    • getMessage

      @NotNull @NotNull String getMessage(@NotNull @NotNull String defaultMessage, @NotNull @NotNull String code, @NotNull @NotNull Locale locale, Object... params)
      Retrieves the I18N message for the specified message code and locale. If the message code is not defined in this I18N resources the specified default message is used. The message is formatted with the provided parameters.
      Parameters:
      defaultMessage - The default message format
      code - The message code
      locale - The locale to retrieve the message for
      params - The message parameters
      Returns:
      The formatted message in the specified locale
    • getMessage

      @NotNull default @NotNull String getMessage(@NotNull @NotNull String defaultMessage, @NotNull @NotNull String[] codes, Object... params)
      Retrieves the I18N message for the specified locale of the first message code efined in this I18N resources of specified message codes. If no message code is defined in this I18N resources the specified default message is used. The message is formatted with the provided parameters.
      Parameters:
      defaultMessage - The default message format
      codes - The message codes, in order of preference
      params - The message parameters
      Returns:
      The formatted message in the I18N context locale
    • getMessage

      @NotNull @NotNull String getMessage(@NotNull @NotNull String defaultMessage, @NotNull @NotNull String[] codes, @NotNull @NotNull Locale locale, Object... params)
      Retrieves the I18N message for the specified locale of the first message code efined in this I18N resources of specified message codes. If no message code is defined in this I18N resources the specified default message is used. The message is formatted with the provided parameters.
      Parameters:
      defaultMessage - The default message format
      codes - The message codes, in order of preference
      locale - The locale to retrieve the message for
      params - The message parameters
      Returns:
      The formatted message in the specified locale