Class I18nMessages

java.lang.Object
sonia.scm.i18n.I18nMessages

public final class I18nMessages extends Object
The I18nMessages class instantiates a class and initializes all String fields with values from a resource bundle. The resource bundle must have the same name as the class. Each field which should be initialized from the bundle, must match a key in the resource bundle or is annotated with a I18n annotation which holds the key. I18nMessages injects also the locale and the bundle if it founds a field with the corresponding type.
Since:
1.37
  • Method Details

    • get

      public static <T> T get(Class<T> msgClass)
      Type Parameters:
      T - type of message class
      Parameters:
      msgClass - message class
      Returns:
      instance of message class
    • get

      public static <T> T get(Class<T> msgClass, jakarta.servlet.http.HttpServletRequest request)
      Same as get(java.lang.Class, java.util.Locale), with locale from servlet request (ServletRequest.getLocale()).
      Type Parameters:
      T - type of message class
      Parameters:
      msgClass - message class
      request - servlet request
    • get

      public static <T> T get(Class<T> msgClass, Locale locale)
      Returns an instance of the given message class with all message fields initialized.
      Type Parameters:
      T - type of the message class
      Parameters:
      msgClass - message class
      locale - locale