Class GlobalMessageUtil

java.lang.Object
org.pentaho.di.i18n.GlobalMessageUtil

public class GlobalMessageUtil extends Object
  • Field Details

    • FAILOVER_LOCALE

      public static final Locale FAILOVER_LOCALE
      Used when the preferred locale (as defined by the user) is not available.
    • langChoice

      protected static final LanguageChoice langChoice
    • threadLocales

      protected static final ThreadLocal<Locale> threadLocales
  • Constructor Details

    • GlobalMessageUtil

      public GlobalMessageUtil()
  • Method Details

    • formatErrorMessage

      public static String formatErrorMessage(String key, String msg)
    • getString

      public static String getString(ResourceBundle bundle, String key) throws MissingResourceException
      Throws:
      MissingResourceException
    • getErrorString

      public static String getErrorString(ResourceBundle bundle, String key)
    • getString

      public static String getString(ResourceBundle bundle, String key, String param1)
    • getErrorString

      public static String getErrorString(ResourceBundle bundle, String key, String param1)
    • getString

      public static String getString(ResourceBundle bundle, String key, String param1, String param2)
    • getErrorString

      public static String getErrorString(ResourceBundle bundle, String key, String param1, String param2)
    • getString

      public static String getString(ResourceBundle bundle, String key, String param1, String param2, String param3)
    • getErrorString

      public static String getErrorString(ResourceBundle bundle, String key, String param1, String param2, String param3)
    • getString

      public static String getString(ResourceBundle bundle, String key, String param1, String param2, String param3, String param4)
    • getString

      public static String getString(ResourceBundle bundle, String key, String param1, String param2, String param3, String param4, String param5)
    • getString

      public static String getString(ResourceBundle bundle, String key, String param1, String param2, String param3, String param4, String param5, String param6)
    • getErrorString

      public static String getErrorString(ResourceBundle bundle, String key, String param1, String param2, String param3, String param4)
    • setLocale

      public static void setLocale(Locale newLocale)
    • getLocale

      public static Locale getLocale()
    • getActiveLocales

      public static LinkedHashSet<Locale> getActiveLocales()
      Returns a LinkedHashSet of Locales for consideration when localizing text. The LinkedHashSet contains the user selected preferred Locale, the failover Locale (Locale.ENGLISH) and the Locale.ROOT.
      Returns:
      Returns a LinkedHashSet of Locales for consideration when translating text
    • calculateString

      public static String calculateString(String[] pkgNames, String key, Object[] parameters, Class<?> resourceClass, String bundleName)
      Calls calculateString(String[], String, Object[], Class, String, boolean) with the logNotFoundError parameter set to true to ensure proper error logging when the localized string cannot be found.
    • calculateString

      public static String calculateString(String[] pkgNames, String key, Object[] parameters, Class<?> resourceClass, String bundleName, boolean fallbackOnRoot)
    • calculateString

      public static String calculateString(String[] pkgNames, String key, Object[] parameters, Class<?> resourceClass, String bundleName, boolean logNotFoundError, boolean fallbackOnRoot)
      Returns the localized string for the given key and parameters in a bundle defined by the the concatenation of the package names defined in packageName and @code bundleName} (the first valid combination of packageName + bundleName wins), sing the provided resourceClass's class loader.
      Parameters:
      pkgNames - an array of packages potentially containing the localized messages the first one found to contain the messages is the one that is used to localize the message
      key - the message key being looked up
      parameters - parameters within the looked up message
      resourceClass - the class whose class loader is used to getch the resource bundle
      bundleName - the name of the message bundle
      logNotFoundError - determines whether an error is logged when the localized string cannot be found - it can be used to suppress the log in cases where it is known that various combinations of parameters will be tried to fetch the message, to avoid unnecessary error logging.
      fallbackOnRoot - if true, and a ResourceBundle cannot be found for a given Locale, falls back on the ROOT Locale
      Returns:
      the localized string for the given key and parameters in a bundle defined by the the concatenation of the package names defined in packageName and @code bundleName} (the first valid combination of packageName + @code bundleName} wins), sing the provided resourceClass's class loader
    • getBundle

      public static ResourceBundle getBundle(String packagePath, Class<?> resourceClass) throws MissingResourceException
      Retrieve a resource bundle of the default or fail-over locales.
      Parameters:
      packagePath - The package to search in
      resourceClass - the class to use to resolve the bundle
      Returns:
      The resource bundle
      Throws:
      MissingResourceException - in case both resource bundles couldn't be found.
    • getBundle

      public static ResourceBundle getBundle(Locale locale, String packagePath, Class<?> resourceClass)
    • getBundle

      public static ResourceBundle getBundle(Locale locale, String packagePath, Class<?> resourceClass, boolean fallbackOnRoot)
      Returns a ResourceBundle corresponding to the given Locale package and resource class. Falls-back on the ROOT Locale, if the fallbackOnRoot flag is true and the requested Locale is not available.
      Parameters:
      locale - the Locale for which the ResourceBundle is being requested
      packagePath -
      resourceClass -
      fallbackOnRoot - if true, and a ResourceBundle cannot be found for the requested Locale, falls back on the ROOT Locale
      Returns:
      a ResourceBundle corresponding to the given Locale package and resource class
    • getLocaleString

      protected static String getLocaleString(Locale locale)
      Returns a string corresponding to the locale (Example: "en", "en_US").
      Parameters:
      locale - The Locale whose string representation it being returned
      Returns:
      a string corresponding to the locale (Example: "en", "en_US").
    • isMissingKey

      protected static boolean isMissingKey(String string)
      Returns true if the given string is null or is in the format of a missing key: !key!.
      Parameters:
      string -
      Returns:
      true if the given string is null or is in the format of a missing key: !key!.