Class Msg

java.lang.Object
org.compiere.util.Msg

public final class Msg extends Object
Contain static methods to access AD_Message, AD_Element and its translations.
Version:
$Id: Msg.java,v 1.2 2006/07/30 00:54:36 jjanke Exp $
Author:
Jorg Janke
  • Method Details

    • get

      public static Msg get()
      Get the singleton Message instance
      Returns:
      Msg
    • getMsgMap

      public CCache<String,String> getMsgMap(String ad_language)
      Get Language specific Message Map
      Parameters:
      ad_language - Language Key
      Returns:
      HashMap of Language
    • getElementMap

      public CCache<String,String> getElementMap(String ad_language)
      Get language specific translation map for AD_Element
      Parameters:
      ad_language -
      Returns:
      ad_element map
    • getElementPrintNameMap

      public CCache<String,String> getElementPrintNameMap(String ad_language)
      Get language specific translation map for AD_Element print name
      Parameters:
      ad_language -
      Returns:
      map of element column name:print name
    • reset

      public void reset()
      Reset/clear message cache
    • getLanguages

      public String[] getLanguages()
      Return an array of the installed Languages
      Returns:
      Array of loaded Languages or null
    • isLoaded

      public boolean isLoaded(String language)
      Check if Language is loaded
      Parameters:
      language - Language code
      Returns:
      true, if language is loaded
    • getMsg

      public static String getMsg(String ad_language, String AD_Message)
      Get translated text for AD_Message
      Parameters:
      ad_language - - Language
      AD_Message - - Message Key
      Returns:
      translated text
    • getMsg

      public static String getMsg(Properties ctx, String AD_Message)
      Get translated text message for AD_Message
      Parameters:
      ctx - Context to retrieve language
      AD_Message - - Message Key
      Returns:
      translated text
    • getMsg

      public static String getMsg(Language language, String AD_Message)
      Get translated text message for AD_Message
      Parameters:
      language - Language
      AD_Message - - Message Key
      Returns:
      translated text
    • getMsg

      public static String getMsg(String ad_language, String AD_Message, boolean getText)
      Get translated text message for AD_Message
      Parameters:
      ad_language - - Language
      AD_Message - - Message Key
      getText - if true only return Text, if false only return Tip
      Returns:
      translated text
    • getMsg

      public static String getMsg(Properties ctx, String AD_Message, boolean getText)
      Get translated text message for AD_Message
      Parameters:
      ctx - Context to retrieve language
      AD_Message - Message Key
      getText - if true only return Text, if false only return Tip
      Returns:
      translated text
    • getMsg

      public static String getMsg(Language language, String AD_Message, boolean getText)
      Get translated text message for AD_Message
      Parameters:
      language - Language
      AD_Message - Message Key
      getText - if true only return Text, if false only return Tip
      Returns:
      translated text
    • getMsg

      public static String getMsg(Properties ctx, String AD_Message, Object[] args)
      Get translated text for AD_Message with parameters
      Parameters:
      ctx - Context to retrieve language
      AD_Message - Message key
      args - MessageFormat arguments
      Returns:
      translated text
      See Also:
    • getMsg

      public static String getMsg(Language language, String AD_Message, Object[] args)
      Get translated text for AD_Message with parameters
      Parameters:
      language - Language
      AD_Message - Message key
      args - MessageFormat arguments
      Returns:
      translated text
      See Also:
    • getMsg

      public static String getMsg(String ad_language, String AD_Message, Object[] args)
      Get translated text for AD_Message with parameters
      Parameters:
      ad_language - Language
      AD_Message - Message key
      args - MessageFormat arguments
      Returns:
      translated text
      See Also:
    • getAmtInWords

      public static String getAmtInWords(Language language, String amount)
      Get Amount in Words
      Parameters:
      language - language
      amount - numeric amount (352.80)
      Returns:
      amount in words (three*five*two 80/100)
    • getElement

      public static String getElement(String ad_language, String ColumnName, boolean isSOTrx)
      Get Translation for Element
      Parameters:
      ad_language - language
      ColumnName - element column name
      isSOTrx - if false PO terminology is used (if exists)
      Returns:
      Translated Element Name or "" if not found
    • getElement

      public static String getElement(String ad_language, String ColumnName, boolean isSOTrx, boolean isPrintName)
      Get Translation for Element
      Parameters:
      ad_language - language
      ColumnName - element column name
      isSOTrx - if false PO terminology is used (if exists)
      isPrintName - if true, return element PrintName instead of element Name
      Returns:
      Translated Element Name/PrintName of the Column or "" if not found
    • getElement

      public static String getElement(Properties ctx, String ColumnName)
      Get Translation for Element using Sales terminology
      Parameters:
      ctx - context
      ColumnName - element column name
      Returns:
      Translated Element Name of the Column or "" if not found
    • getElement

      public static String getElement(Properties ctx, String ColumnName, boolean isSOTrx)
      Get Translation for Element
      Parameters:
      ctx - context
      ColumnName - element column name
      isSOTrx - sales transaction
      Returns:
      Translated Element Name of the Column or "" if not found
    • translate

      public static String translate(String ad_language, boolean isSOTrx, String text)
      "Translate" text.
                      - Check AD_Message.AD_Message   ->      MsgText
                      - Check AD_Element.ColumnName   ->      Name
        
      If checking AD_Element, the SO terminology is used.
      Parameters:
      ad_language - Language
      isSOTrx - sales order context
      text - Text - Message Value or Element Column Name
      Returns:
      translated text or original text if not found
    • translate

      public static String translate(String ad_language, boolean isSOTrx, String text, boolean isPrintName)
      "Translate" text.
                      - Check AD_Message.AD_Message   ->      MsgText
                      - Check AD_Element.ColumnName   ->      Name/PrintName
        
      If checking AD_Element, the SO terminology is used.
      Parameters:
      ad_language - Language
      isSOTrx - sales order context
      text - Text - Message Value or Element Column Name
      isPrintName - if true, return element PrintName instead of element Name
      Returns:
      translated text or original text if not found
    • translate

      public static String translate(String ad_language, String text)
      "Translate" text (SO Context).
                      - Check AD_Message.AD_Message   ->      MsgText
                      - Check AD_Element.ColumnName   ->      Name
        
      If checking AD_Element, the SO terminology is used.
      Parameters:
      ad_language - Language
      text - Text - Message Value or Element Column Name
      Returns:
      translated text or original text if not found
    • translate

      public static String translate(Properties ctx, String text)
      "Translate" text.
                      - Check Context
                      - Check AD_Message.AD_Message   ->      MsgText
                      - Check AD_Element.ColumnName   ->      Name
        
      Parameters:
      ctx - Context
      text - Text - Message Value or Element Column Name
      Returns:
      translated text or original text if not found
    • translate

      public static String translate(Language language, String text)
      "Translate" text.
                      - Check AD_Message.AD_Message   ->      MsgText
                      - Check AD_Element.ColumnName   ->      Name
        
      Parameters:
      language - Language
      text - Message Value or Element Column Name
      Returns:
      translated text or original text if not found
    • parseTranslation

      public static String parseTranslation(Properties ctx, String text)
      Translate elements enclosed in "@" (at sign)
      Parameters:
      ctx - Context
      text - Text
      Returns:
      translated text or original text if not found
    • hasTranslation

      public static boolean hasTranslation(String adLanguage, String text)
      Is translation exists for text
      Parameters:
      adLanguage -
      text -
      Returns:
      true if translation exists for text and adLanguage
    • getCleanMsg

      public static String getCleanMsg(Properties ctx, String string)
      Get translated text message for AD_Message, ampersand cleaned (used to indicate shortcut)
      Parameters:
      ctx - Context to retrieve language
      string - AD_Message - Message Key
      Returns:
      translated text