Class LocalizationUtils

java.lang.Object
org.jppf.utils.LocalizationUtils

public final class LocalizationUtils extends Object
Utility methods to localize messages in the JPPF components.
Author:
Laurent Cohen
  • Constructor Details

    • LocalizationUtils

      public LocalizationUtils()
  • Method Details

    • getLocalized

      public static String getLocalized(String baseName, String key)
      Get a localized property value.
      Parameters:
      baseName - the base name to use, in combination with the default locale, to lookup the appropriate resource bundle.
      key - the key for the localized value to lookup.
      Returns:
      the name localized through the default locale information, or the key itself if it could not be localized.
    • getLocalized

      public static String[] getLocalized(String baseName, String... keys)
      Get a localized array of property values.
      Parameters:
      baseName - the base name to use, in combination with the default locale, to lookup the appropriate resource bundle.
      keys - the keys for which to lookup a localized value.
      Returns:
      an array of localized values looked up using the default locale. If a key could not be localized, it is returned as the value.
    • getLocalized

      public static String[] getLocalized(String baseName, Locale locale, String... keys)
      Get a localized array of property values.
      Parameters:
      baseName - the base name to use, in combination with the default locale, to lookup the appropriate resource bundle.
      locale - the locale for which to lookup localized values.
      keys - the keys for which to lookup a localized value.
      Returns:
      an array of localized values looked up using the default locale. If a key could not be localized, it is returned as the value.
    • getLocalized

      public static String getLocalized(String baseName, String key, Locale locale)
      Get a localized property value.
      Parameters:
      baseName - the base name to use, in combination with the default locale, to lookup the appropriate resource bundle.
      key - the key for the localized value to lookup.
      locale - the locale for which to lookup localized values.
      Returns:
      the name localized through the default locale information, or the key itself if it could not be localized.
    • getLocalized

      public static String getLocalized(String baseName, String key, String def)
      Get a localized property value.
      Parameters:
      baseName - the base name to use, in combination with the default locale, to lookup the appropriate resource bundle.
      key - the key for the localized value to lookup.
      def - the default value to return if no localized string could be found.
      Returns:
      the name localized through the default locale information, or the key itself if it could not be localized.
    • getLocalized

      public static String getLocalized(String baseName, String key, String def, Locale locale)
      Get a localized property value for the specified locale.
      Parameters:
      baseName - the base name to use, in combination with the default locale, to lookup the appropriate resource bundle.
      key - the key for the localized value to lookup.
      def - the default value to return if no localized string could be found.
      locale - the locale for which to lookup a localized value.
      Returns:
      the name localized through the default locale information, or the key itself if it could not be localized.
    • getLocalized

      public static String getLocalized(String baseName, String key, String def, Locale locale, Object... params)
      Get a localized property value for the specified locale.
      Parameters:
      baseName - the base name to use, in combination with the default locale, to lookup the appropriate resource bundle.
      key - the key for the localized value to lookup.
      def - the default value to return if no localized string could be found.
      locale - the locale for which to lookup a localized value.
      params - optional parameters for parametrized messages.
      Returns:
      the name localized through the default locale information, or the key itself if it could not be localized.
    • getLocalisationBase

      public static String getLocalisationBase(String base, String filename)
      Compute a localisation base path from a base folder and a file name.
      Parameters:
      base - the base folder path as a string.
      filename - the filename from which to get the resource bundle name.
      Returns:
      the complete path to a resource bundle.