Package org.pentaho.di.i18n
Class GlobalMessageUtil
java.lang.Object
org.pentaho.di.i18n.GlobalMessageUtil
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final LocaleUsed when the preferred locale (as defined by the user) is not available.protected static final LanguageChoiceprotected static final ThreadLocal<Locale> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcalculateString(String[] pkgNames, String key, Object[] parameters, Class<?> resourceClass, String bundleName) CallscalculateString(String[], String, Object[], Class, String, boolean)with thelogNotFoundErrorparameter set totrueto ensure proper error logging when the localized string cannot be found.static StringcalculateString(String[] pkgNames, String key, Object[] parameters, Class<?> resourceClass, String bundleName, boolean fallbackOnRoot) static StringcalculateString(String[] pkgNames, String key, Object[] parameters, Class<?> resourceClass, String bundleName, boolean logNotFoundError, boolean fallbackOnRoot) Returns the localized string for the givenkeyandparametersin a bundle defined by the the concatenation of the package names defined inpackageNameand @code bundleName} (the first valid combination ofpackageName+bundleNamewins), sing the providedresourceClass's class loader.static StringformatErrorMessage(String key, String msg) static LinkedHashSet<Locale>Returns aLinkedHashSetofLocales for consideration when localizing text.static ResourceBundleRetrieve a resource bundle of the default or fail-over locales.static ResourceBundlestatic ResourceBundleReturns aResourceBundlecorresponding to the givenLocalepackage and resource class.static StringgetErrorString(ResourceBundle bundle, String key) static StringgetErrorString(ResourceBundle bundle, String key, String param1) static StringgetErrorString(ResourceBundle bundle, String key, String param1, String param2) static StringgetErrorString(ResourceBundle bundle, String key, String param1, String param2, String param3) static StringgetErrorString(ResourceBundle bundle, String key, String param1, String param2, String param3, String param4) static Localeprotected static StringgetLocaleString(Locale locale) Returns a string corresponding to the locale (Example: "en", "en_US").static StringgetString(ResourceBundle bundle, String key) static StringgetString(ResourceBundle bundle, String key, String param1) static StringgetString(ResourceBundle bundle, String key, String param1, String param2) static Stringstatic StringgetString(ResourceBundle bundle, String key, String param1, String param2, String param3, String param4) static StringgetString(ResourceBundle bundle, String key, String param1, String param2, String param3, String param4, String param5) static StringgetString(ResourceBundle bundle, String key, String param1, String param2, String param3, String param4, String param5, String param6) protected static booleanisMissingKey(String string) Returns true if the givenstringis null or is in the format of a missing key: !key!.static void
-
Field Details
-
FAILOVER_LOCALE
Used when the preferred locale (as defined by the user) is not available. -
langChoice
-
threadLocales
-
-
Constructor Details
-
GlobalMessageUtil
public GlobalMessageUtil()
-
-
Method Details
-
formatErrorMessage
-
getString
- Throws:
MissingResourceException
-
getErrorString
-
getString
-
getErrorString
-
getString
-
getErrorString
public static String getErrorString(ResourceBundle bundle, String key, String param1, String param2) -
getString
-
getErrorString
-
getString
-
getString
-
getString
-
getErrorString
-
setLocale
-
getLocale
-
getActiveLocales
Returns aLinkedHashSetofLocales for consideration when localizing text. TheLinkedHashSetcontains the user selected preferredLocale, the failoverLocale(Locale.ENGLISH) and theLocale.ROOT.- Returns:
- Returns a
LinkedHashSetofLocales for consideration when translating text
-
calculateString
public static String calculateString(String[] pkgNames, String key, Object[] parameters, Class<?> resourceClass, String bundleName) CallscalculateString(String[], String, Object[], Class, String, boolean)with thelogNotFoundErrorparameter set totrueto ensure proper error logging when the localized string cannot be found. -
calculateString
-
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 givenkeyandparametersin a bundle defined by the the concatenation of the package names defined inpackageNameand @code bundleName} (the first valid combination ofpackageName+bundleNamewins), sing the providedresourceClass'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 messagekey- the message key being looked upparameters- parameters within the looked up messageresourceClass- the class whose class loader is used to getch the resource bundlebundleName- the name of the message bundlelogNotFoundError- 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 aResourceBundlecannot be found for a givenLocale, falls back on the ROOTLocale- Returns:
- the localized string for the given
keyandparametersin a bundle defined by the the concatenation of the package names defined inpackageNameand @code bundleName} (the first valid combination ofpackageName+ @code bundleName} wins), sing the providedresourceClass'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 inresourceClass- the class to use to resolve the bundle- Returns:
- The resource bundle
- Throws:
MissingResourceException- in case both resource bundles couldn't be found.
-
getBundle
-
getBundle
public static ResourceBundle getBundle(Locale locale, String packagePath, Class<?> resourceClass, boolean fallbackOnRoot) Returns aResourceBundlecorresponding to the givenLocalepackage and resource class. Falls-back on the ROOTLocale, if thefallbackOnRootflag is true and the requested Locale is not available.- Parameters:
locale- theLocalefor which theResourceBundleis being requestedpackagePath-resourceClass-fallbackOnRoot- if true, and aResourceBundlecannot be found for the requestedLocale, falls back on the ROOTLocale- Returns:
- a
ResourceBundlecorresponding to the givenLocalepackage and resource class
-
getLocaleString
Returns a string corresponding to the locale (Example: "en", "en_US").- Parameters:
locale- TheLocalewhose string representation it being returned- Returns:
- a string corresponding to the locale (Example: "en", "en_US").
-
isMissingKey
Returns true if the givenstringis null or is in the format of a missing key: !key!.- Parameters:
string-- Returns:
- true if the given
stringis null or is in the format of a missing key: !key!.
-