Interface IMessageLocalizer

All Superinterfaces:
Serializable
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface IMessageLocalizer extends Serializable
Interface for objects that can localize message keys in a given locale, optional with parameters.
Author:
XIMA MEDIA GmbH
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    canLocalize(Locale locale, String messageKey)
    Checks if a message key can be localized in the given local
    localize(Locale locale, String messageKey, Object... parameters)
    Localizes a message key in the given locale.
  • Method Details

    • canLocalize

      default boolean canLocalize(Locale locale, String messageKey)
      Checks if a message key can be localized in the given local

      The default implementation invokes localize(Locale, String, Object...) and checks if the result is not null and does not start or end with a question mark (which indicates a missing localization in our convention).

      Parameters:
      locale - The locale to check.
      messageKey - The message key to check.
      Returns:
      True if the message key can be localized, false otherwise.
    • localize

      String localize(Locale locale, String messageKey, Object... parameters)
      Localizes a message key in the given locale.
      Parameters:
      locale - The locale to localize the message in.
      messageKey - The message key to localize.
      parameters - Optional parameters to replace in the message.
      Returns:
      The localized message.