Package org.omegat.util
Class Language
java.lang.Object
org.omegat.util.Language
- All Implemented Interfaces:
Comparable<Object>
This class is here, because the Locale has hard-coded '_' inside, and we must
adhere to ISO standard LL-CC.
This class tries to follow TMX Specification on languages, which is based on RFC 3066, i.e.
- Language is composed from 1-8 alpha (A-Za-z) chars, then "-", then 1-8 alpha/digit chars (A-Za-z0-9).
- Case insensitive
- Case is not altered by this class, even though there exist conventions for capitalization (ISO 3166 recommends that country codes are capitalized (MN Mongolia), and ISO 639 recommends that language codes are written in lower case (mn Mongolian)).
-
Constructor Summary
ConstructorsConstructorDescriptionCreates 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.Creates a new instance of Language, based on Locale -
Method Summary
Modifier and TypeMethodDescriptionintbooleanIndicates whether some other language is "equal to" this one.Returns only a country (YY).Returns a name for the language that is appropriate for display to the user.Returns a string representation as an ISO language code (XX-YY).Returns only a language (XX).Get a list of all languages known to the program.returns the Java localeReturns a string representation as a Java locale (xx_YY).Returns a string representation as a Microsoft locale (xx-yy).static Stringstatic StringinthashCode()Returns a hash code value for the language.booleanisSameCountryLanguage(String target) booleanisSameCountryLanguage(Language target) Returns true if two languages have the same language and country (eg.booleanisSameLanguage(String target) booleanisSameLanguage(Language target) Returns true if two languages have the same language code (eg.booleanDetermine whether or not the language is space-delimited.toString()Returns a string representation as an ISO language code (XX-YY).static booleanverifyLangCode(String code) Verify the correctness of a language or country codestatic booleanverifySingleLangCode(String code) Verifies whether the language code is OK.
-
Constructor Details
-
Language
Creates a new instance of Language, based on Locale -
Language
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. E.g., sr-Latn-RS, which represents Serbian ('sr') written using Latin script ('Latn') as used in Serbia ('RS'). This form is described in BCP47.
-
-
Method Details
-
getDisplayName
Returns a name for the language that is appropriate for display to the user. -
toString
Returns a string representation as an ISO language code (XX-YY). -
getLanguage
Returns a string representation as an ISO language code (XX-YY). -
getLocaleCode
Returns a string representation as a Java locale (xx_YY). -
getLocaleLCID
Returns a string representation as a Microsoft locale (xx-yy). -
getLocale
returns the Java locale -
getLanguageCode
Returns only a language (XX). -
getCountryCode
Returns only a country (YY). -
isSpaceDelimited
public boolean isSpaceDelimited()Determine whether or not the language is space-delimited. Only Chinese, Japanese, and Tibetan are not space-delimited.- See Also:
-
getLanguages
Get a list of all languages known to the program.- Returns:
- Unmodifiable list of languages
-
equals
Indicates whether some other language is "equal to" this one. -
hashCode
public int hashCode()Returns a hash code value for the language. Basically returns a hashcode of the underlying Locale object. -
compareTo
- Specified by:
compareToin interfaceComparable<Object>
-
verifyLangCode
Verify the correctness of a language or country code- Parameters:
code- A string containing a language or country code- Returns:
trueorfalse
-
verifySingleLangCode
Verifies whether the language code is OK. -
isSameLanguage
Returns true if two languages have the same language code (eg. fr-FR / fr-CA; es-419/es-BO). -
isSameLanguage
-
isSameCountryLanguage
Returns true if two languages have the same language and country (eg. fr-FR / fr-FR). Note that it is slightly different thanLanguage.equals()because of the possible use of BCP47 tags (eg. en-GB-x-ulster / en-GB-x-scotland) -
isSameCountryLanguage
-
getLowerCaseLanguageFromLocale
-
getUpperCaseCountryFromLocale
-