Class Language

  • All Implemented Interfaces:
    Serializable

    public class Language
    extends Object
    implements Serializable
    Language Management.
    Version:
    $Id: Language.java,v 1.2 2006/07/30 00:52:23 jjanke Exp $
    Author:
    Jorg Janke
    See Also:
    Serialized Form
    • Constructor Detail

      • Language

        public Language​(String name,
                        String AD_Language,
                        Locale locale,
                        Boolean decimalPoint,
                        String javaDatePattern,
                        MediaSize mediaSize)
        Define Language
        Parameters:
        name - - displayed value, e.g. English
        AD_Language - - the code of system supported language, e.g. en_US (might be different than Locale - i.e. if the system does not support the language)
        locale - - the Locale, e.g. Locale.US
        decimalPoint - true if Decimal Point - if null, derived from Locale
        javaDatePattern - Java date pattern as not all locales are defined - if null, derived from Locale
        mediaSize - default media size
      • Language

        public Language​(String name,
                        String AD_Language,
                        Locale locale)
        Define Language with A4 and default decimal point and date format
        Parameters:
        name - - displayed value, e.g. English
        AD_Language - - the code of system supported language, e.g. en_US (might be different than Locale - i.e. if the system does not support the language)
        locale - - the Locale, e.g. Locale.US
      • Language

        public Language​(Language copy)
        Copy constructor
        Parameters:
        copy -
    • Method Detail

      • getLanguageCount

        public static int getLanguageCount()
        Get Number of Languages
        Returns:
        Language count
      • getLanguage

        public static Language getLanguage​(int index)
        Get Language
        Parameters:
        index - index
        Returns:
        Language
      • getLanguage

        public static Language getLanguage​(String langInfo)
        Get Language. If language does not exist, create it on the fly assuming that it is valid
        Parameters:
        langInfo - either language (en) or locale (en-US) or display name
        Returns:
        Name (e.g. Deutsch)
      • setBaseLanguage

        public static void setBaseLanguage​(String baselang)
      • isBaseLanguage

        public static boolean isBaseLanguage​(String langInfo)
        Is it the base language
        Parameters:
        langInfo - either language (en) or locale (en-US) or display name
        Returns:
        true if base language
      • getBaseLanguage

        public static Language getBaseLanguage()
        Get Base Language
        Returns:
        Base Language
      • getBaseAD_Language

        public static String getBaseAD_Language()
        Get Base Language code. (e.g. en-US)
        Returns:
        Base Language
      • getLocale

        public static Locale getLocale​(String langInfo)
        Get Supported Locale
        Parameters:
        langInfo - either language (en) or locale (en-US) or display name
        Returns:
        Supported Locale
      • getAD_Language

        public static String getAD_Language​(String langInfo)
        Get Supported Language
        Parameters:
        langInfo - either language (en) or locale (en-US) or display name
        Returns:
        AD_Language (e.g. en-US)
      • getAD_Language

        public static String getAD_Language​(Locale locale)
        Get Supported Language
        Parameters:
        locale - Locale
        Returns:
        AD_Language (e.g. en-US)
      • getName

        public static String getName​(String langInfo)
        Get Language Name
        Parameters:
        langInfo - either language (en) or locale (en-US) or display name
        Returns:
        Language Name (e.g. English)
      • isDecimalPoint

        public static boolean isDecimalPoint​(String langInfo)
        Returns true if Decimal Point (not comma)
        Parameters:
        langInfo - either language (en) or locale (en-US) or display name
        Returns:
        use of decimal point
      • getNames

        public static String[] getNames()
        Get Display names of supported languages
        Returns:
        Array of Language names
      • getLoginLanguage

        public static Language getLoginLanguage()
        Get Current Login Language
        Returns:
        login language
      • setLoginLanguage

        public static void setLoginLanguage​(Language language)
        Set Current Login Language
        Parameters:
        language - language
      • getName

        public String getName()
        Get Language Name. e.g. English
        Returns:
        name
      • getAD_Language

        public String getAD_Language()
        Get Application Dictionary Language (system supported). e.g. en-US
        Returns:
        AD_Language
      • setAD_Language

        public void setAD_Language​(String AD_Language)
        Set Application Dictionary Language (system supported).
        Parameters:
        AD_Language - e.g. en-US
      • getLocale

        public Locale getLocale()
        Get Locale
        Returns:
        locale
      • setLocale

        public void setLocale​(Locale locale)
        Overwrite Locale
        Parameters:
        locale - locale
      • getLanguageCode

        public String getLanguageCode()
        Get Language Code. e.g. en - derived from Locale
        Returns:
        language code
      • isLeftToRight

        public boolean isLeftToRight()
        Component orientation is Left To Right
        Returns:
        true if left-to-right
      • isDecimalPoint

        public boolean isDecimalPoint()
        Returns true if Decimal Point (not comma)
        Returns:
        use of decimal point
      • isBaseLanguage

        public boolean isBaseLanguage()
        Is This the Base Language
        Returns:
        true if base Language
      • setDateFormat

        public void setDateFormat​(String javaDatePattern)
        Set Date Pattern. The date format is not checked for correctness
        Parameters:
        javaDatePattern - for details see java.text.SimpleDateFormat, format must be able to be converted to database date format by using the upper case function. It also must have leading zero for day and month.
      • getDateFormat

        public SimpleDateFormat getDateFormat()
        Get (Short) Date Format. The date format must parseable by org.compiere.grid.ed.MDocDate i.e. leading zero for date and month
        Returns:
        date format MM/dd/yyyy - dd.MM.yyyy
      • getDateTimeFormat

        public SimpleDateFormat getDateTimeFormat()
        Get Date Time Format. Used for Display only
        Returns:
        Date Time format MMM d, yyyy h:mm:ss a z -or- dd.MM.yyyy HH:mm:ss z -or- j nnn aaaa, H' ?????? 'm' ????'
      • getTimeFormat

        public SimpleDateFormat getTimeFormat()
        Get Time Format. Used for Display only
        Returns:
        Time format h:mm:ss z or HH:mm:ss z
      • getDBdatePattern

        public String getDBdatePattern()
        Get Database Date Pattern. Derive from date pattern (make upper case and replace month as word with MM)
        Returns:
        date pattern
      • getMediaSize

        public MediaSize getMediaSize()
        Get default MediaSize
        Returns:
        media size
      • setMediaSize

        public void setMediaSize​(MediaSize size)
        Set default MediaSize
        Parameters:
        size - media size
      • toString

        public String toString()
        String Representation
        Overrides:
        toString in class Object
        Returns:
        string representation
      • hashCode

        public int hashCode()
        Hash Code
        Overrides:
        hashCode in class Object
        Returns:
        hashcode
      • equals

        public boolean equals​(Object obj)
        Equals. Two languages are equal, if they have the same AD_Language
        Overrides:
        equals in class Object
        Parameters:
        obj - compare
        Returns:
        true if AD_Language is the same
      • main

        public static void main​(String[] args)
        Test
        Parameters:
        args - ignored