Class Str

java.lang.Object
org.reldb.toolbox.il8n.Str

public class Str extends Object
Message registry.
  • Constructor Details

    • Str

      public Str()
  • Method Details

    • setDisplayLanguage

      public static void setDisplayLanguage(String displayLanguage)
      Set the display language. Default is Locale.getDefault().getDisplayLanguage().
      Parameters:
      displayLanguage - Language identifier, of the kind returned by Locale.getDefault().getDisplayLanguage().
    • getDisplayLanguage

      public static String getDisplayLanguage()
      Get the display language.
      Returns:
      Language identifier, of the kind returned by Locale.getDefault().getDisplayLanguage().
    • addTranslations

      public static void addTranslations(String language, Map<String,​String> sourceFormatToTranslatedFormat)
      Set the source format string to target format string map for a given language.
      Parameters:
      language - Language identifier, of the kind returned by Locale.getDefault().getDisplayLanguage().
      sourceFormatToTranslatedFormat - A Map from source format strings defined in code to translated strings in the specified language.
    • addTranslation

      public static void addTranslation(String language, String sourceFormat, String translatedFormat)
      Add a format string translation for a given language.
      Parameters:
      language - Language identifier, of the kind returned by Locale.getDefault().getDisplayLanguage().
      sourceFormat - Source format string, of the kind used by java.text.MessageFormat.
      translatedFormat - Translated format string, of the kind used by java.text.MessageFormat.
    • getTranslation

      public static String getTranslation(String language, String sourceFormat)
      Get a translation of a source format string for a given language.
      Parameters:
      language - Language identifier, of the kind returned by Locale.getDefault().getDisplayLanguage().
      sourceFormat - Source format string, of the kind used by java.text.MessageFormat.
      Returns:
      Translated format string, of the kind used by java.text.MessageFormat.
    • getTranslation

      public static String getTranslation(String sourceFormat)
      Get a translation of a source format string for language returned by getDisplayLanguage().
      Parameters:
      sourceFormat - Source format string, of the kind used by java.text.MessageFormat.
      Returns:
      Translated format string, of the kind used by java.text.MessageFormat.
    • ing

      public static String ing(Msg formatSpecification, Object... arguments)
      Given a message containing a format specification per java.text.MessageFormat and optional arguments, return the string as its locale-specific, possibly-translated message.
      Parameters:
      formatSpecification - Static specification of messagee format.
      arguments - Message arguments.
      Returns:
      Displayable message.