public class Language
extends java.lang.Object
implements java.lang.Comparable<java.lang.Object>
This class tries to follow TMX Specification on languages, which is based on RFC 3066, i.e.
Constructor and Description |
---|
Language(java.util.Locale locale)
Creates a new instance of Language, based on Locale
|
Language(java.lang.String str)
Creates a new instance of Language, based on a string of a form "XX_YY"
or "XX-YY", where XX is a language code composed from 1-8 alpha (A-Za-z)
chars, and YY is a country ISO code composed from 1-8 alpha/digit
(A-Za-z0-9) chars.
The form xx-xxxx-xx is also accepted, where "xxxx" is a 4 alpha characters script as defined in ISO 15924. |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(java.lang.Object o) |
boolean |
equals(java.lang.Object lang)
Indicates whether some other language is "equal to" this one.
|
java.lang.String |
getCountryCode()
Returns only a country (YY).
|
java.lang.String |
getDisplayName()
Returns a name for the language that is appropriate for display to the
user.
|
java.lang.String |
getLanguage()
Returns a string representation as an ISO language code (XX-YY).
|
java.lang.String |
getLanguageCode()
Returns only a language (XX).
|
static java.util.List<Language> |
getLanguages()
Get a list of all languages known to the program.
|
java.util.Locale |
getLocale()
returns the Java locale
|
java.lang.String |
getLocaleCode()
Returns a string representation as a Java locale (xx_YY).
|
java.lang.String |
getLocaleLCID()
Returns a string representation as a Microsoft locale (xx-yy).
|
int |
hashCode()
Returns a hash code value for the language.
|
static boolean |
isRTL(java.lang.String language)
Check if language is Right-To-Left oriented.
|
boolean |
isSameCountryLanguage(Language target)
Returns true if two languages have the same language and country (eg.
|
boolean |
isSameCountryLanguage(java.lang.String target) |
boolean |
isSameLanguage(Language target)
Returns true if two languages have the same language code (eg.
|
boolean |
isSameLanguage(java.lang.String target) |
boolean |
isSpaceDelimited()
Determine whether or not the language is space-delimited.
|
static boolean |
localeIsRTL()
Check if locale is Right-To-Left oriented.
|
java.lang.String |
toString()
Returns a string representation as an ISO language code (XX-YY).
|
static boolean |
verifyLangCode(java.lang.String code)
Verify the correctness of a language or country code
|
static boolean |
verifySingleLangCode(java.lang.String code)
Verifies whether the language code is OK.
|
public Language(java.util.Locale locale)
public Language(java.lang.String str)
public java.lang.String getDisplayName()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getLanguage()
public java.lang.String getLocaleCode()
public java.lang.String getLocaleLCID()
public java.util.Locale getLocale()
public java.lang.String getLanguageCode()
public java.lang.String getCountryCode()
public boolean isSpaceDelimited()
public static java.util.List<Language> getLanguages()
public boolean equals(java.lang.Object lang)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public int compareTo(java.lang.Object o)
compareTo
in interface java.lang.Comparable<java.lang.Object>
public static boolean verifyLangCode(java.lang.String code)
code
- A string containing a language or country codetrue
or false
public static boolean verifySingleLangCode(java.lang.String code)
public boolean isSameLanguage(Language target)
public boolean isSameLanguage(java.lang.String target)
public boolean isSameCountryLanguage(Language target)
Language.equals()
because of the possible use of BCP47 tags (eg. en-GB-x-ulster /
en-GB-x-scotland)public boolean isSameCountryLanguage(java.lang.String target)
public static boolean localeIsRTL()
public static boolean isRTL(java.lang.String language)
language
- ISO-639-2 language code