|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.okapi.common.LocaleId
public final class LocaleId
Holds the normalized identifier for a given language/locale.
| Field Summary | |
|---|---|
static LocaleId |
ARABIC
LocaleId constant for "ar". |
static LocaleId |
CHINA_CHINESE
LocaleId constant for "zh-cn". |
static LocaleId |
EMPTY
An empty locale. |
static LocaleId |
ENGLISH
LocaleId constant for "en". |
static LocaleId |
FRENCH
LocaleId constant for "fr". |
static LocaleId |
GERMAN
LocaleId constant for "de". |
static LocaleId |
ITALIAN
LocaleId constant for "it". |
static LocaleId |
JAPANESE
LocaleId constant for "ja". |
static LocaleId |
PORTUGUESE
LocaleId constant for "pt". |
static LocaleId |
RUSSIAN
LocaleId constant for "ru". |
static LocaleId |
SPANISH
LocaleId constant for "es". |
static LocaleId |
TAIWAN_CHINESE
LocaleId constant for "zh-tw". |
| Constructor Summary | |
|---|---|
LocaleId(java.util.Locale loc)
Creates a new LocaleId for the given Java Locale. |
|
LocaleId(java.lang.String language)
Creates a new LocaleId for a given language code. |
|
LocaleId(java.lang.String locId,
boolean normalize)
Creates a new LocaleId object from a locale identifier. |
|
LocaleId(java.lang.String language,
java.lang.String region)
Creates a new LocaleId for a given language code and region code. |
|
LocaleId(java.lang.String language,
java.lang.String region,
java.lang.String userPart)
Creates a new LocaleId for a given language code, region code, and a user part. |
|
| Method Summary | |
|---|---|
LocaleId |
clone()
Returns a clone of this LocaleId. |
int |
compareTo(java.lang.Object arg)
Compares this LocaleId with a given object. |
boolean |
equals(java.lang.Object arg)
Indicates if a given object is equal to this localeId object. |
static LocaleId |
fromBCP47(java.lang.String langtag)
Creates a new LocaleId from a BCP-47 language tag. |
static LocaleId |
fromPOSIXLocale(java.lang.String locId)
Creates a new LocaleId from a POSIX locale identifier. |
static LocaleId |
fromString(java.lang.String locId)
Creates a new LocaleId from a locale identifier (and validate it). |
static LocaleId[] |
getAvailableLocales()
Gets an array of the LocaleId objects for all the Java locales installed on the system. |
java.lang.String |
getLanguage()
Gets the language code for this LocaleId. |
java.lang.String |
getRegion()
Gets the region code for this LocaleId. |
java.lang.String |
getUserPart()
Gets the user part of this LocaleId. |
int |
hashCode()
Returns a hash code value for this LocaleId. |
static boolean |
isBidirectional(LocaleId locId)
Indicates if a given locale usually uses a bi-directional script. |
static java.lang.String |
replaceVariables(java.lang.String input,
LocaleId srcLoc,
LocaleId trgLoc)
Replaces the locale/language variables in a given input string by their runtime values. |
static java.lang.String |
replaceVariables(java.lang.String input,
java.lang.String srcLoc,
java.lang.String trgLoc)
Replaces the locale/language variables in a given input string by their runtime values. |
boolean |
sameLanguageAs(LocaleId other)
Indicates if the language of a given LocaleId is the same as the one of this LocaleId. |
boolean |
sameLanguageAs(java.lang.String langCode)
Indicates if a given string has the same language as the one of this LocaleId. |
boolean |
sameRegionAs(LocaleId other)
Indicates if the region of a given LocaleId is the same as the one of this LocaleId. |
boolean |
sameRegionAs(java.lang.String langCode)
Indicates if a given string has the same region as the one of this LocaleId. |
boolean |
sameUserPartAs(LocaleId other)
Indicates if the user part of a given LocaleId is the same as the one of this LocaleId. |
boolean |
sameUserPartAs(java.lang.String langCode)
Indicates if a given string has the same user part as the one of this LocaleId. |
static java.lang.String[] |
splitLanguageCode(java.lang.String language)
Splits a given ISO language tag (e.g. |
java.lang.String |
toBCP47()
Gets the BCP-47 language tag for this LocaleId. |
java.util.Locale |
toJavaLocale()
Creates a new Java Locale object from this LocaleId. |
java.lang.String |
toPOSIXLocaleId()
Gets a POSIX locale identifier for this LocaleId. |
java.lang.String |
toString()
Gets the string representation of the LocaleId. |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final LocaleId EMPTY
public static final LocaleId ARABIC
public static final LocaleId CHINA_CHINESE
public static final LocaleId TAIWAN_CHINESE
public static final LocaleId ENGLISH
public static final LocaleId FRENCH
public static final LocaleId GERMAN
public static final LocaleId ITALIAN
public static final LocaleId JAPANESE
public static final LocaleId PORTUGUESE
public static final LocaleId RUSSIAN
public static final LocaleId SPANISH
| Constructor Detail |
|---|
public LocaleId(java.lang.String locId,
boolean normalize)
locId - a LocaleId stringnormalize - true if it needs to be normalized the string,
false to use as-it. When use as-it, the identifier is expected to be in lower-cases and use '-'
for separator.
java.lang.IllegalArgumentException - if the argument in invalid.public LocaleId(java.lang.String language)
LocaleId(String, boolean) to create a new LocaleId from a locale identifier.
language - the language code (e.g. "de" for German).
java.lang.IllegalArgumentException - if the argument in invalid.
public LocaleId(java.lang.String language,
java.lang.String region)
language - the language code (e.g. "es" for Spanish).region - the region code (e.g. "es" for Spain or "005" for South America.
This parameter is ignored if null or empty.
java.lang.IllegalArgumentException - if the argument in invalid.
public LocaleId(java.lang.String language,
java.lang.String region,
java.lang.String userPart)
language - the language code (e.g. "es" for Spanish).region - the region code (e.g. "es" for Spain or "005" for South America.userPart - the user part of locale.
The latter two parameters are ignored if null or empty.
java.lang.IllegalArgumentException - if the argument in invalid.public LocaleId(java.util.Locale loc)
loc - the Java Locale object to use.
java.lang.IllegalArgumentException - if the argument in invalid.| Method Detail |
|---|
public static java.lang.String replaceVariables(java.lang.String input,
LocaleId srcLoc,
LocaleId trgLoc)
input - the string with the variables.srcLoc - the source locale code (can be null).trgLoc - the target locale code (can be null).
public static java.lang.String replaceVariables(java.lang.String input,
java.lang.String srcLoc,
java.lang.String trgLoc)
input - the string with the variables.srcLoc - the source locale code (can be null).trgLoc - the target locale code (can be null).
public java.lang.String toString()
toString in class java.lang.Objectpublic LocaleId clone()
clone in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object arg)
equals in class java.lang.Objectarg - the object to compare. This can be a LocaleId object
or a string. Any other object will always return false. If the parameter
is a string it is normalized before being compared.
public int compareTo(java.lang.Object arg)
compareTo in interface java.lang.Comparable<java.lang.Object>arg - the object to compare. If the parameter is a string it is normalized
before being compared.
public static LocaleId fromString(java.lang.String locId)
new LocaleId(locId, true);
locId - the locale identifier to use (it will be normalized).
java.lang.IllegalArgumentException - if the argument is invalid.public static LocaleId fromPOSIXLocale(java.lang.String locId)
locId - the POSIX locale identifier (e.g. "de-at.UTF-8@EURO")
java.lang.IllegalArgumentException - if the argument is invalid.public java.lang.String toPOSIXLocaleId()
public static LocaleId fromBCP47(java.lang.String langtag)
langtag - the language tag to use (e.g. "fr-CA")
public java.lang.String toBCP47()
public java.util.Locale toJavaLocale()
public java.lang.String getLanguage()
public java.lang.String getRegion()
public java.lang.String getUserPart()
public boolean sameLanguageAs(LocaleId other)
other - the LocaleId object to compare.
public boolean sameLanguageAs(java.lang.String langCode)
langCode - the string to compare.
public boolean sameRegionAs(LocaleId other)
other - the LocaleId object to compare.
public boolean sameRegionAs(java.lang.String langCode)
langCode - the string to compare.
public boolean sameUserPartAs(LocaleId other)
other - the LocaleId object to compare.
public boolean sameUserPartAs(java.lang.String langCode)
langCode - the string to compare.
public static LocaleId[] getAvailableLocales()
public static java.lang.String[] splitLanguageCode(java.lang.String language)
LocaleId object is not desirable.
This method supports only simple ISO codes (not complex BCP-47 tags).
language - the language code to process.
public static boolean isBidirectional(LocaleId locId)
Note that this is not perfect as some languages use several scripts.
locId - the locale to check.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||