Enum Class LanguageCode
- All Implemented Interfaces:
Serializable,Comparable<LanguageCode>,java.lang.constant.Constable
Enum names of this enum themselves are represented by ISO 639-1 code (2-letter lower-case alphabets).
// List all the language codes. for (LanguageCode code : LanguageCode.values()) { // For example, "[ar] Arabic" is printed. System.out.format("[%s] %s\n", code, code.getName()); } // Get a LanguageCode instance by ISO 639-1 code. LanguageCode code = LanguageCode.getByCode("fr"); // Convert to a Locale instance. Locale locale = code.toLocale(); // Get a LanguageCode by a Locale instance. code = LanguageCode.getByLocale(locale); // Get a list by a regular expression for names. // // The list will contain: // // LanguageCode.an : Aragonese // LanguageCode.ja : Japanese // LanguageCode.jv : Javanese // LanguageCode.su : Sundanese // LanguageCode.zh : Chinese // List<LanguageCode> list = LanguageCode.findByName(".*nese");
- Author:
- Takahiko Kawasaki
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionAzerbaijani (aze).Belarusian (bel).West Frisian (fry).Interlingua (ina).Indonesian (ind).Interlingue (ile).Kalaallisut (kal).Luxembourgish (ltz).Limburgish (lim).Lithuanian (lit).Luba-Katanga (lub).Marshallese (mah).Deprecated.Portuguese (por).Kinyarwanda (kin).Northern Sami (sme).Undefined.Vietnamese (vie). -
Method Summary
Modifier and TypeMethodDescriptionstatic List<LanguageCode>findByName(String regex) Get a list ofLanguageCodeby a name regular expression.static List<LanguageCode>findByName(Pattern pattern) Get a list ofLanguageCodeby a name pattern.Get ISO 639-2 language code (3-letter lowercase code(s)).static LanguageCodestatic LanguageCodestatic LanguageCodegetByCodeIgnoreCase(String code) static LanguageCodegetByLocale(Locale locale) Get aLanguageCodethat corresponds to the language code of the givenLocaleinstance.getName()Get the language name.toLocale()Convert thisLanguageCodeinstance to aLocaleinstance.static LanguageCodeReturns the enum constant of this class with the specified name.static LanguageCode[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
undefined
Undefined.This is not an official ISO 639-1 code.
- Since:
- 1.14
-
aa
-
ab
-
ae
-
af
-
ak
-
am
-
an
-
ar
-
as
-
av
-
ay
-
az
Azerbaijani (aze). -
ba
-
be
Belarusian (bel). -
bg
-
bh
-
bi
-
bm
-
bn
-
bo
-
br
-
bs
-
ca
-
ce
-
ch
-
co
-
cr
-
cs
-
cu
-
cv
-
cy
-
da
-
de
-
dv
-
dz
-
ee
-
el
-
en
-
eo
-
es
-
et
-
eu
-
fa
-
ff
-
fi
-
fj
-
fo
-
fr
-
fy
West Frisian (fry). -
ga
-
gd
-
gl
-
gn
-
gu
-
gv
-
ha
-
he
-
hi
-
ho
-
hr
-
ht
-
hu
-
hy
-
hz
-
ia
Interlingua (ina). -
id
Indonesian (ind). -
ie
Interlingue (ile). -
ig
-
ii
-
ik
-
io
-
is
-
it
-
iu
-
ja
-
jv
-
ka
-
kg
-
ki
-
kj
-
kk
-
kl
Kalaallisut (kal). -
km
-
kn
-
ko
-
kr
-
ks
-
ku
-
kv
-
kw
-
ky
-
la
-
lb
Luxembourgish (ltz). -
lg
-
li
Limburgish (lim). -
ln
-
lo
-
lt
Lithuanian (lit). -
lu
Luba-Katanga (lub). -
lv
-
mg
-
mh
Marshallese (mah). -
mi
-
mk
-
ml
-
mn
-
mr
-
ms
-
mt
-
my
-
na
-
nb
-
nd
-
ne
-
ng
-
nl
-
nn
-
no
Deprecated.nbshould be used. -
nr
-
nv
-
ny
-
oc
-
oj
-
om
-
or
-
os
-
pa
-
pi
-
pl
-
ps
-
pt
Portuguese (por). -
qu
-
rm
-
rn
-
ro
-
ru
-
rw
Kinyarwanda (kin). -
sa
-
sc
-
sd
-
se
Northern Sami (sme). -
sg
-
si
-
sk
-
sl
-
sm
-
sn
-
so
-
sq
-
sr
-
ss
-
st
-
su
-
sv
-
sw
-
ta
-
te
-
tg
-
th
-
ti
-
tk
-
tl
-
tn
-
to
-
tr
-
ts
-
tt
-
tw
-
ty
-
ug
-
uk
-
ur
-
uz
-
ve
-
vi
Vietnamese (vie). -
vo
-
wa
-
wo
-
xh
-
yi
-
yo
-
za
-
zh
-
zu
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getByCode
Get aLanguageCodethat corresponds to a given ISO 639-1 code (2-letter lowercase code) or ISO 639-2 code (3-letter lowercase code).This method calls
getByCode(code, true). Note that the behavior has changed since the version 1.13. In the older versions, this method was an alias ofgetByCode(code, false).- Parameters:
code- An ISO 639-1 code (2-letter lowercase code) or an ISO 639-2 code (3-letter lowercase code). Or "undefined" (case sensitive). Note that if the given code is one of legacy language codes ("iw", "ji" and "in"), it is treated as its official counterpart ("he", "yi" and "id", respectively). For example, if "in" is given, this method returnsLanguageCode.id.- Returns:
- A
LanguageCodeinstance, ornullif not found.
-
getByCodeIgnoreCase
Get aLanguageCodethat corresponds to a given ISO 639-1 code (2-letter lowercase code) or ISO 639-2 code (3-letter lowercase code).This method calls
getByCode(code, false).- Parameters:
code- An ISO 639-1 code (2-letter lowercase code) or an ISO 639-2 code (3-letter lowercase code). Or "undefined" (case insensitive). Note that if the given code is one of legacy language codes ("iw", "ji" and "in"), it is treated as its official counterpart ("he", "yi" and "id", respectively). For example, if "in" is given, this method returnsLanguageCode.id.- Returns:
- A
LanguageCodeinstance, ornullif not found. - Since:
- 1.13
-
getByCode
Get aLanguageCodethat corresponds to a given ISO 639-1 code (2-letter lowercase code) or ISO 639-2 code (3-letter lowercase code).- Parameters:
code- An ISO 639-1 code (2-letter lowercase code) or an ISO 639-2 code (3-letter lowercase code). Or "undefined" (its case sensitivity depends on the value ofcaseSensitive). Note that if the given code is one of legacy language codes ("iw", "ji" and "in"), it is treated as its official counterpart ("he", "yi" and "id", respectively). For example, if "in" is given, this method returnsLanguageCode.id.caseSensitive- Iftrue, the given code should consist of lowercase letters only. Iffalse, this method internally canonicalizes the given code byString.toLowerCase()and then performs search. For example,getByCode("JA", true)returnsnull, but on the other hand,getByCode("JA", false)returnsLanguageCode.ja.- Returns:
- A
LanguageCodeinstance, ornullif not found.
-
getByLocale
Get aLanguageCodethat corresponds to the language code of the givenLocaleinstance.- Parameters:
locale- ALocaleinstance.- Returns:
- A
LanguageCodeinstance, ornullif not found. WhengetLanguage()method of the givenLocaleinstance returnsnullor an empty string,LanguageCode.undefinedis returned. - See Also:
-
findByName
Get a list ofLanguageCodeby a name regular expression.This method is almost equivalent to
findByName(Pattern.compile(regex)).- Parameters:
regex- Regular expression for names.- Returns:
- List of
LanguageCode. If nothing has matched, an empty list is returned. - Throws:
IllegalArgumentException-regexisnull.PatternSyntaxException-regexfailed to be compiled.- Since:
- 1.11
-
findByName
Get a list ofLanguageCodeby a name pattern.For example, the list obtained by the code snippet below:
Pattern pattern = Pattern.compile(".*nese"); List<LanguageCode> list = LanguageCode.findByName(pattern);contains 5
LanguageCodes as listed below.- Parameters:
pattern- Pattern to match names.- Returns:
- List of
LanguageCode. If nothing has matched, an empty list is returned. - Throws:
IllegalArgumentException-patternisnull.- Since:
- 1.11
-
getName
Get the language name.- Returns:
- The language name.
-
toLocale
Convert thisLanguageCodeinstance to aLocaleinstance.In most cases, this method creates a new
Localeinstance every time it is called, but someLanguageCodeinstances return their corresponding entries inLocaleclass. For example,LanguageCode.jaalways returnsLocale.JAPANESE.The table below lists
LanguageCodeentries whosetoLocale()do not create newLocaleinstances but return entries inLocaleclass.- Returns:
- A
Localeinstance that matches thisLanguageCode.
-
getAlpha3
Get ISO 639-2 language code (3-letter lowercase code(s)).Most languages have just one corresponding ISO 639-2 code, but some languages have two ISO 639-2 codes. They are known as "bibliographic" code (ISO 639-2/B code) and "terminological" code (ISO 639-2/T code). This method returns ISO 639-2/T code. If you want to get ISO 639-2/B code, write like below.
LanguageCode alpha2 = ...;
LanguageAlpha3Codealpha3B = alpha2.getAlpha3().getAlpha3B();The above code does no harm for most
LanguageCodes that have just one ISO 639-2 code.getAlpha3B()of suchLanguageAlpha3Codeinstances just return themselves (=thisobject).The table below lists languages having two ISO 639-2 codes.
ISO 639-1 ISO 639-2/T ISO 639-2/B Language bobodtibTibetan eueusbaqBasque cscesczeCzech cycymwelWelsh dedeugerGerman elellgreGreek fafasperPersian frfrafreFrench hyhyearmArmenian isisliceIcelandic kakatgeoGeorgian mimrimaoMāori mkmkdmacMacedonian msmsamayMalay mymyaburBurmese nlnlddutDutch roronrumRomanian skslksloSlovak sqsqialbAlbanian - Returns:
- ISO 639-2 language code.
- Since:
- 1.1
-
nbshould be used.