Class Translator

java.lang.Object
net.adoptopenjdk.icedteaweb.i18n.Translator

public class Translator extends Object
Utility class to provide simple methods to help localize messages.
  • Field Details

  • Constructor Details

    • Translator

      private Translator()
    • Translator

      Translator(String fullyQualifiedBundleBaseName, Locale locale)
    • Translator

      Translator(ResourceBundle resources, Locale locale)
  • Method Details

    • getBundle

      private static ResourceBundle getBundle(String fullyQualifiedBundleBaseName, Locale locale)
    • getInstance

      public static Translator getInstance()
    • addBundle

      public static void addBundle(String fullyQualifiedBundleBaseName)
    • addBundle

      public static void addBundle(ResourceBundle bundle)
    • addBundleImpl

      void addBundleImpl(ResourceBundle bundle)
    • R

      public static String R(String message)
      Return a translated (localized) version of the message
      Parameters:
      message - the message to translate
      Returns:
      a string representing the localized message
    • R

      public static String R(String message, Object... params)
      Parameters:
      message - key to be found in properties
      params - params to be expanded to message
      Returns:
      the localized string for the message
    • translate

      public String translate(String key, Object... args)
      Parameters:
      key - key to be found in properties
      args - params to be expanded to message
      Returns:
      the localized resource string using the specified arguments.
    • translate

      private String translate(String key)
      Returns the localized resource string identified by the specified key. If the message is empty, a null is returned.