java.lang.Object
io.github.belgif.rest.problem.i18n.I18N

public class I18N extends Object
Helper class for I18N (Internationalization).
  • Field Details

  • Method Details

    • getRequestLocale

      public static Locale getRequestLocale()
      Get the locale of the current request.
      Returns:
      the locale of the current request
    • getLocalizedDetail

      public static String getLocalizedDetail(Class<? extends Problem> problemClass, Object... args)
      Get a localized detail string with key "[problem-class].detail" from the resource bundle "[problem-package].Messages".

      For example, for problem class = com.acme.custom.CustomProblem, the localized string with key "CustomProblem.detail" would be loaded from resource bundle "com.acme.custom.Messages".

      Parameters:
      problemClass - the context class
      args - the optional arguments that will be resolved with String.format(String, Object...)
      Returns:
      the localized string
    • getLocalizedString

      public static String getLocalizedString(String key, Object... args)
      Get a localized string from the default Belgif resource bundle.
      Parameters:
      key - the key
      args - the optional arguments that will be resolved with String.format(String, Object...)
      Returns:
      the localized string
    • getLocalizedString

      public static String getLocalizedString(Class<?> context, String key, Object... args)
      Get a localized string from the resource bundle "[context-package].Messages".

      For example, for context class = com.acme.custom.CustomProblem, the localized string would be loaded from resource bundle "com.acme.custom.Messages".

      Parameters:
      context - the context class
      key - the key
      args - the optional arguments that will be resolved with String.format(String, Object...)
      Returns:
      the localized string
    • setEnabled

      public static void setEnabled(boolean enabled)
      Enable or disable I18N.
      Parameters:
      enabled - true to enable, false to disable
    • isEnabled

      public static boolean isEnabled()
      Return whether I18N is enabled.
      Returns:
      whether I18N is enabled