public enum LanguageCode extends Enum<LanguageCode>
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");
Enum Constant and Description |
---|
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.
nb should 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
|
undefined
Undefined.
|
ur
|
uz
|
ve
|
vi
Vietnamese
(
vie ). |
vo
|
wa
|
wo
|
xh
|
yi
|
yo
|
za
|
zh
|
zu
|
Modifier and Type | Method and Description |
---|---|
static List<LanguageCode> |
findByName(Pattern pattern)
Get a list of
LanguageCode by a name pattern. |
static List<LanguageCode> |
findByName(String regex)
Get a list of
LanguageCode by a name regular expression. |
LanguageAlpha3Code |
getAlpha3()
Get ISO 639-2
language code (3-letter lowercase code(s)).
|
static LanguageCode |
getByCode(String code)
|
static LanguageCode |
getByCode(String code,
boolean caseSensitive)
|
static LanguageCode |
getByCodeIgnoreCase(String code)
|
static LanguageCode |
getByLocale(Locale locale)
Get a
LanguageCode that corresponds to the language code of
the given Locale instance. |
String |
getName()
Get the language name.
|
Locale |
toLocale()
Convert this
LanguageCode instance to a Locale instance. |
static LanguageCode |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static LanguageCode[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final LanguageCode undefined
This is not an official ISO 639-1 code.
public static final LanguageCode aa
public static final LanguageCode ab
public static final LanguageCode ae
public static final LanguageCode af
public static final LanguageCode ak
public static final LanguageCode am
public static final LanguageCode an
public static final LanguageCode ar
public static final LanguageCode as
public static final LanguageCode av
public static final LanguageCode ay
public static final LanguageCode az
aze
).public static final LanguageCode ba
public static final LanguageCode be
bel
).public static final LanguageCode bg
public static final LanguageCode bh
public static final LanguageCode bi
public static final LanguageCode bm
public static final LanguageCode bn
public static final LanguageCode bo
public static final LanguageCode br
public static final LanguageCode bs
public static final LanguageCode ca
public static final LanguageCode ce
public static final LanguageCode ch
public static final LanguageCode co
public static final LanguageCode cr
public static final LanguageCode cs
public static final LanguageCode cu
public static final LanguageCode cv
public static final LanguageCode cy
public static final LanguageCode da
public static final LanguageCode de
public static final LanguageCode dv
public static final LanguageCode dz
public static final LanguageCode ee
public static final LanguageCode el
public static final LanguageCode en
public static final LanguageCode eo
public static final LanguageCode es
public static final LanguageCode et
public static final LanguageCode eu
public static final LanguageCode fa
public static final LanguageCode ff
public static final LanguageCode fi
public static final LanguageCode fj
public static final LanguageCode fo
public static final LanguageCode fr
public static final LanguageCode fy
fry
).public static final LanguageCode ga
public static final LanguageCode gd
public static final LanguageCode gl
public static final LanguageCode gn
public static final LanguageCode gu
public static final LanguageCode gv
public static final LanguageCode ha
public static final LanguageCode he
public static final LanguageCode hi
public static final LanguageCode ho
public static final LanguageCode hr
public static final LanguageCode ht
public static final LanguageCode hu
public static final LanguageCode hy
public static final LanguageCode hz
public static final LanguageCode ia
ina
).public static final LanguageCode id
ind
).public static final LanguageCode ie
ile
).public static final LanguageCode ig
public static final LanguageCode ii
public static final LanguageCode ik
public static final LanguageCode io
public static final LanguageCode is
public static final LanguageCode it
public static final LanguageCode iu
public static final LanguageCode ja
public static final LanguageCode jv
public static final LanguageCode ka
public static final LanguageCode kg
public static final LanguageCode ki
public static final LanguageCode kj
public static final LanguageCode kk
public static final LanguageCode kl
kal
).public static final LanguageCode km
public static final LanguageCode kn
public static final LanguageCode ko
public static final LanguageCode kr
public static final LanguageCode ks
public static final LanguageCode ku
public static final LanguageCode kv
public static final LanguageCode kw
public static final LanguageCode ky
public static final LanguageCode la
public static final LanguageCode lb
ltz
).public static final LanguageCode lg
public static final LanguageCode li
lim
).public static final LanguageCode ln
public static final LanguageCode lo
public static final LanguageCode lt
lit
).public static final LanguageCode lu
lub
).public static final LanguageCode lv
public static final LanguageCode mg
public static final LanguageCode mh
mah
).public static final LanguageCode mi
public static final LanguageCode mk
public static final LanguageCode ml
public static final LanguageCode mn
public static final LanguageCode mr
public static final LanguageCode ms
public static final LanguageCode mt
public static final LanguageCode my
public static final LanguageCode na
public static final LanguageCode nb
public static final LanguageCode nd
public static final LanguageCode ne
public static final LanguageCode ng
public static final LanguageCode nl
public static final LanguageCode nn
public static final LanguageCode no
nb
should be used.public static final LanguageCode nr
public static final LanguageCode nv
public static final LanguageCode ny
public static final LanguageCode oc
public static final LanguageCode oj
public static final LanguageCode om
public static final LanguageCode or
public static final LanguageCode os
public static final LanguageCode pa
public static final LanguageCode pi
public static final LanguageCode pl
public static final LanguageCode ps
public static final LanguageCode pt
por
).public static final LanguageCode qu
public static final LanguageCode rm
public static final LanguageCode rn
public static final LanguageCode ro
public static final LanguageCode ru
public static final LanguageCode rw
kin
).public static final LanguageCode sa
public static final LanguageCode sc
public static final LanguageCode sd
public static final LanguageCode se
sme
).public static final LanguageCode sg
public static final LanguageCode si
public static final LanguageCode sk
public static final LanguageCode sl
public static final LanguageCode sm
public static final LanguageCode sn
public static final LanguageCode so
public static final LanguageCode sq
public static final LanguageCode sr
public static final LanguageCode ss
public static final LanguageCode st
public static final LanguageCode su
public static final LanguageCode sv
public static final LanguageCode sw
public static final LanguageCode ta
public static final LanguageCode te
public static final LanguageCode tg
public static final LanguageCode th
public static final LanguageCode ti
public static final LanguageCode tk
public static final LanguageCode tl
public static final LanguageCode tn
public static final LanguageCode to
public static final LanguageCode tr
public static final LanguageCode ts
public static final LanguageCode tt
public static final LanguageCode tw
public static final LanguageCode ty
public static final LanguageCode ug
public static final LanguageCode uk
public static final LanguageCode ur
public static final LanguageCode uz
public static final LanguageCode ve
public static final LanguageCode vi
vie
).public static final LanguageCode vo
public static final LanguageCode wa
public static final LanguageCode wo
public static final LanguageCode xh
public static final LanguageCode yi
public static final LanguageCode yo
public static final LanguageCode za
public static final LanguageCode zh
public static final LanguageCode zu
public static LanguageCode[] values()
for (LanguageCode c : LanguageCode.values()) System.out.println(c);
public static LanguageCode valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic String getName()
public Locale toLocale()
LanguageCode
instance to a Locale
instance.
In most cases, this method creates a new Locale
instance
every time it is called, but some LanguageCode
instances return
their corresponding entries in Locale
class. For example,
LanguageCode.ja
always returns Locale.JAPANESE
.
The table below lists LanguageCode
entries whose toLocale()
do not create new Locale
instances but return entries in
Locale
class.
Locale
instance that matches this LanguageCode
.public LanguageAlpha3Code getAlpha3()
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 = ...;LanguageAlpha3Code
alpha3B = alpha2.getAlpha3()
.getAlpha3B()
;
The above code does no harm for most LanguageCode
s that have
just one ISO 639-2 code. getAlpha3B()
of such LanguageAlpha3Code
instances just return
themselves (= this
object).
The table below lists languages having two ISO 639-2 codes.
ISO 639-1 | ISO 639-2/T | ISO 639-2/B | Language |
---|---|---|---|
bo |
bod |
tib |
Tibetan |
eu |
eus |
baq |
Basque |
cs |
ces |
cze |
Czech |
cy |
cym |
wel |
Welsh |
de |
deu |
ger |
German |
el |
ell |
gre |
Greek |
fa |
fas |
per |
Persian |
fr |
fra |
fre |
French |
hy |
hye |
arm |
Armenian |
is |
isl |
ice |
Icelandic |
ka |
kat |
geo |
Georgian |
mi |
mri |
mao |
Māori |
mk |
mkd |
mac |
Macedonian |
ms |
msa |
may |
Malay |
my |
mya |
bur |
Burmese |
nl |
nld |
dut |
Dutch |
ro |
ron |
rum |
Romanian |
sk |
slk |
slo |
Slovak |
sq |
sqi |
alb |
Albanian |
public static LanguageCode getByCode(String code)
LanguageCode
that 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 of getByCode(code, false)
.
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 returns LanguageCode.id
.LanguageCode
instance, or null
if not found.public static LanguageCode getByCodeIgnoreCase(String code)
LanguageCode
that 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)
.
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 returns LanguageCode.id
.LanguageCode
instance, or null
if not found.public static LanguageCode getByCode(String code, boolean caseSensitive)
LanguageCode
that corresponds to a given
ISO 639-1 code
(2-letter lowercase code) or
ISO 639-2 code
(3-letter lowercase code).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 of caseSensitive
).
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 returns LanguageCode.id
.caseSensitive
- If true
, the given code should consist of lowercase letters only.
If false
, this method internally canonicalizes the given code by
String.toLowerCase()
and then performs search. For example,
getByCode("JA", true)
returns null
, but on the other hand,
getByCode("JA", false)
returns LanguageCode.ja
.LanguageCode
instance, or null
if not found.public static LanguageCode getByLocale(Locale locale)
LanguageCode
that corresponds to the language code of
the given Locale
instance.locale
- A Locale
instance.LanguageCode
instance, or null
if not found.
When getLanguage()
method of the
given Locale
instance returns null
or an
empty string, LanguageCode.undefined
is
returned.Locale.getLanguage()
public static List<LanguageCode> findByName(String regex)
LanguageCode
by a name regular expression.
This method is almost equivalent to findByName
(Pattern.compile(regex))
.
regex
- Regular expression for names.LanguageCode
. If nothing has matched,
an empty list is returned.IllegalArgumentException
- regex
is null
.PatternSyntaxException
- regex
failed to be compiled.public static List<LanguageCode> findByName(Pattern pattern)
LanguageCode
by 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 LanguageCode
s as listed below.
pattern
- Pattern to match names.LanguageCode
. If nothing has matched,
an empty list is returned.IllegalArgumentException
- pattern
is null
.Copyright © 2021. All rights reserved.