com.neovisionaries.i18n
Enum LocaleCode

java.lang.Object
  extended by java.lang.Enum<LocaleCode>
      extended by com.neovisionaries.i18n.LocaleCode
All Implemented Interfaces:
Serializable, Comparable<LocaleCode>

public enum LocaleCode
extends Enum<LocaleCode>

Locale code.

The entries of this enum was generated based on the output from Locale.getAvailableLocales() of Java SE 7, but locales whose format do not match either 'xx' or 'xx-XX' were excluded.

 // List all the locale codes.
 for (LocaleCode code : LocaleCode.values())
 {
     String language = code.getLanguage().getName();
     String country  = code.getCountry() != null
                     ? code.getCountry().getName() : null;

     // For example, "[de-DE] German, Germany" is printed.
     System.out.format("[%s] %s, %s\n", code, language, country);
 }

 // Get a LocaleCode instance in various ways.
 LocaleCode code;
 code = LocaleCode.getByCode("en-GB");
 code = LocaleCode.getByCode("es", "ES");
 code = LocaleCode.getByLocale(new Locale("pt", "BR"));

 // Convert to a Locale instance.
 Locale locale = LocaleCode.en.toLocale();

 // toLocale() of some LocaleCode instances does not create
 // a new Locale instance but returns a static variable of
 // Locale class instead. See toLocale() for details.
 if (locale == Locale.ENGLISH)
 {
     System.out.println("Locale.en.toLocale() returned Locale.ENGLISH");
 }
 

Author:
Takahiko Kawasaki

Enum Constant Summary
ar
          Arabic
ar_AE
          Arabic, United Arab Emirates
ar_BH
          Arabic, Bahrain
ar_DZ
          Arabic, Algeria
ar_EG
          Arabic, Egypt
ar_IQ
          Arabic, Iraq
ar_JO
          Arabic, Jordan
ar_KW
          Arabic, Kuwait
ar_LB
          Arabic, Lebanon
ar_LY
          Arabic, Libya
ar_MA
          Arabic, Morocco
ar_OM
          Arabic, Oman
ar_QA
          Arabic, Qatar
ar_SA
          Arabic, Saudi Arabia
ar_SD
          Arabic, Sudan
ar_SY
          Arabic, Syrian Arab Republic
ar_TN
          Arabic, Tunisia
ar_YE
          Arabic, Yemen
be
          Belarusian
be_BY
          Belarusian, Belarus
bg
          Bulgarian
bg_BG
          Bulgarian, Bulgaria
ca
          Catalan
ca_ES
          Catalan, Spain
cs
          Czech
cs_CZ
          Czech, Czech Republic
da
          Danish
da_DK
          Danish, Denmark
de
          German
de_AT
          German, Austria
de_CH
          German, Switzerland
de_DE
          German, Germany
de_LU
          German, Luxembourg
el
          Greek
el_CY
          Greek, Cyprus
el_GR
          Greek, Greece
en
          English
en_AU
          English, Australia
en_CA
          English, Canada
en_GB
          English, United Kingdom
en_IE
          English, Ireland
en_IN
          English, India
en_MT
          English, Malta
en_NZ
          English, New Zealand
en_PH
          English, Philippines
en_SG
          English, Singapore
en_US
          English, United States
en_ZA
          English, South Africa
es
          Spanish
es_AR
          Spanish, Argentina
es_BO
          Spanish, Plurinational State of Bolivia
es_CL
          Spanish, Chile
es_CO
          Spanish, Colombia
es_CR
          Spanish, Costa Rica
es_DO
          Spanish, Dominican Republic
es_EC
          Spanish, Ecuador
es_ES
          Spanish, Spain
es_GT
          Spanish, Guatemala
es_HN
          Spanish, Honduras
es_MX
          Spanish, Mexico
es_NI
          Spanish, Nicaragua
es_PA
          Spanish, Panama
es_PE
          Spanish, Peru
es_PR
          Spanish, Puerto Rico
es_PY
          Spanish, Paraguay
es_SV
          Spanish, El Salvador
es_US
          Spanish, United States
es_UY
          Spanish, Uruguay
es_VE
          Spanish, Bolivarian Republic of Venezuela
et
          Estonian
et_EE
          Estonian, Estonia
fi
          Finnish
fi_FI
          Finnish, Finland
fr
          French
fr_BE
          French, Belgium
fr_CA
          French, Canada
fr_CH
          French, Switzerland
fr_FR
          French, France
fr_LU
          French, Luxembourg
ga
          Irish
ga_IE
          Irish, Ireland
he
          Hebrew
he_IL
          Hebrew, Israel
hi_IN
          Hindi, India
hr
          Croatian
hr_HR
          Croatian, Croatia
hu
          Hungarian
hu_HU
          Hungarian, Hungary
id
          Indonesian
id_ID
          Indonesian, Indonesia
is
          Icelandic
is_IS
          Icelandic, Iceland
it
          Italian
it_CH
          Italian, Switzerland
it_IT
          Italian, Italy
ja
          Japanese
ja_JP
          Japanese, Japan
ko
          Korean
ko_KR
          Korean, Republic of Korea
lt
          Lithuanian
lt_LT
          Lithuanian, Lithuania
lv
          Latvian
lv_LV
          Latvian, Latvia
mk
          Macedonian
mk_MK
          Macedonian, The former Yugoslav Republic of Macedonia
ms
          Malay
ms_MY
          Malay, Malaysia
mt
          Maltese
mt_MT
          Maltese, Malta
nl
          Dutch
nl_BE
          Dutch, Belgium
nl_NL
          Dutch, Netherlands
nn_NO
          Norwegian Nynorsk, Norway
no
          Norwegian
no_NO
          Norwegian, Norway
pl
          Polish
pl_PL
          Polish, Poland
pt
          Portuguese
pt_BR
          Portuguese, Brazil
pt_PT
          Portuguese, Portugal
ro
          Romanian
ro_RO
          Romanian, Romania
ru
          Russian
ru_RU
          Russian, Russian Federation
sk
          Slovak
sk_SK
          Slovak, Slovakia
sl
          Slovene
sl_SI
          Slovene, Slovenia
sq
          Albanian
sq_AL
          Albanian, Albania
sr
          Serbian
sr_BA
          Serbian, Bosnia and Herzegovina
sr_CS
          Serbian, Serbia and Montenegro
sr_ME
          Serbian, Montenegro
sr_RS
          Serbian, Serbia
sv
          Swedish
sv_SE
          Swedish, Sweden
th
          Thai
th_TH
          Thai, Thailand
tr
          Turkish
tr_TR
          Turkish, Turkey
uk
          Ukrainian
uk_UA
          Ukrainian, Ukraine
vi
          Vietnamese
vi_VN
          Vietnamese, Viet Nam
zh
          Chinese
zh_CN
          Chinese, China
zh_HK
          Chinese, Hong Kong
zh_SG
          Chinese, Singapore
zh_TW
          Chinese, Taiwan, Province of China
 
Method Summary
static LocaleCode getByCode(String code)
          Get a LocaleCode instance that corresponds to the given code.
static LocaleCode getByCode(String code, boolean caseSensitive)
          Get a LocaleCode instance that corresponds to the given code.
static LocaleCode getByCode(String language, String country)
          Get a LocaleCode instance that corresponds to the given pair of language code and country code.
static LocaleCode getByCode(String language, String country, boolean caseSensitive)
          Get a LocaleCode instance that corresponds to the given pair of language code and country code.
static LocaleCode getByLocale(Locale locale)
          Get a LocaleCode instance that corresponds to the given Locale instance.
 CountryCode getCountry()
          Get the country code.
 LanguageCode getLanguage()
          Get the language code.
 Locale toLocale()
          Convert this LocaleCode instance to a Locale instance.
 String toString()
          Get the string representation of this locale code.
static LocaleCode valueOf(String name)
          Returns the enum constant of this type with the specified name.
static LocaleCode[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

ar

public static final LocaleCode ar
Arabic


ar_AE

public static final LocaleCode ar_AE
Arabic, United Arab Emirates


ar_BH

public static final LocaleCode ar_BH
Arabic, Bahrain


ar_DZ

public static final LocaleCode ar_DZ
Arabic, Algeria


ar_EG

public static final LocaleCode ar_EG
Arabic, Egypt


ar_IQ

public static final LocaleCode ar_IQ
Arabic, Iraq


ar_JO

public static final LocaleCode ar_JO
Arabic, Jordan


ar_KW

public static final LocaleCode ar_KW
Arabic, Kuwait


ar_LB

public static final LocaleCode ar_LB
Arabic, Lebanon


ar_LY

public static final LocaleCode ar_LY
Arabic, Libya


ar_MA

public static final LocaleCode ar_MA
Arabic, Morocco


ar_OM

public static final LocaleCode ar_OM
Arabic, Oman


ar_QA

public static final LocaleCode ar_QA
Arabic, Qatar


ar_SA

public static final LocaleCode ar_SA
Arabic, Saudi Arabia


ar_SD

public static final LocaleCode ar_SD
Arabic, Sudan


ar_SY

public static final LocaleCode ar_SY
Arabic, Syrian Arab Republic


ar_TN

public static final LocaleCode ar_TN
Arabic, Tunisia


ar_YE

public static final LocaleCode ar_YE
Arabic, Yemen


be

public static final LocaleCode be
Belarusian


be_BY

public static final LocaleCode be_BY
Belarusian, Belarus


bg

public static final LocaleCode bg
Bulgarian


bg_BG

public static final LocaleCode bg_BG
Bulgarian, Bulgaria


ca

public static final LocaleCode ca
Catalan


ca_ES

public static final LocaleCode ca_ES
Catalan, Spain


cs

public static final LocaleCode cs
Czech


cs_CZ

public static final LocaleCode cs_CZ
Czech, Czech Republic


da

public static final LocaleCode da
Danish


da_DK

public static final LocaleCode da_DK
Danish, Denmark


de

public static final LocaleCode de
German


de_AT

public static final LocaleCode de_AT
German, Austria


de_CH

public static final LocaleCode de_CH
German, Switzerland


de_DE

public static final LocaleCode de_DE
German, Germany


de_LU

public static final LocaleCode de_LU
German, Luxembourg


el

public static final LocaleCode el
Greek


el_CY

public static final LocaleCode el_CY
Greek, Cyprus


el_GR

public static final LocaleCode el_GR
Greek, Greece


en

public static final LocaleCode en
English


en_AU

public static final LocaleCode en_AU
English, Australia


en_CA

public static final LocaleCode en_CA
English, Canada


en_GB

public static final LocaleCode en_GB
English, United Kingdom


en_IE

public static final LocaleCode en_IE
English, Ireland


en_IN

public static final LocaleCode en_IN
English, India


en_MT

public static final LocaleCode en_MT
English, Malta


en_NZ

public static final LocaleCode en_NZ
English, New Zealand


en_PH

public static final LocaleCode en_PH
English, Philippines


en_SG

public static final LocaleCode en_SG
English, Singapore


en_US

public static final LocaleCode en_US
English, United States


en_ZA

public static final LocaleCode en_ZA
English, South Africa


es

public static final LocaleCode es
Spanish


es_AR

public static final LocaleCode es_AR
Spanish, Argentina


es_BO

public static final LocaleCode es_BO
Spanish, Plurinational State of Bolivia


es_CL

public static final LocaleCode es_CL
Spanish, Chile


es_CO

public static final LocaleCode es_CO
Spanish, Colombia


es_CR

public static final LocaleCode es_CR
Spanish, Costa Rica


es_DO

public static final LocaleCode es_DO
Spanish, Dominican Republic


es_EC

public static final LocaleCode es_EC
Spanish, Ecuador


es_ES

public static final LocaleCode es_ES
Spanish, Spain


es_GT

public static final LocaleCode es_GT
Spanish, Guatemala


es_HN

public static final LocaleCode es_HN
Spanish, Honduras


es_MX

public static final LocaleCode es_MX
Spanish, Mexico


es_NI

public static final LocaleCode es_NI
Spanish, Nicaragua


es_PA

public static final LocaleCode es_PA
Spanish, Panama


es_PE

public static final LocaleCode es_PE
Spanish, Peru


es_PR

public static final LocaleCode es_PR
Spanish, Puerto Rico


es_PY

public static final LocaleCode es_PY
Spanish, Paraguay


es_SV

public static final LocaleCode es_SV
Spanish, El Salvador


es_US

public static final LocaleCode es_US
Spanish, United States


es_UY

public static final LocaleCode es_UY
Spanish, Uruguay


es_VE

public static final LocaleCode es_VE
Spanish, Bolivarian Republic of Venezuela


et

public static final LocaleCode et
Estonian


et_EE

public static final LocaleCode et_EE
Estonian, Estonia


fi

public static final LocaleCode fi
Finnish


fi_FI

public static final LocaleCode fi_FI
Finnish, Finland


fr

public static final LocaleCode fr
French


fr_BE

public static final LocaleCode fr_BE
French, Belgium


fr_CA

public static final LocaleCode fr_CA
French, Canada


fr_CH

public static final LocaleCode fr_CH
French, Switzerland


fr_FR

public static final LocaleCode fr_FR
French, France


fr_LU

public static final LocaleCode fr_LU
French, Luxembourg


ga

public static final LocaleCode ga
Irish


ga_IE

public static final LocaleCode ga_IE
Irish, Ireland


he

public static final LocaleCode he
Hebrew


he_IL

public static final LocaleCode he_IL
Hebrew, Israel


hi_IN

public static final LocaleCode hi_IN
Hindi, India


hr

public static final LocaleCode hr
Croatian


hr_HR

public static final LocaleCode hr_HR
Croatian, Croatia


hu

public static final LocaleCode hu
Hungarian


hu_HU

public static final LocaleCode hu_HU
Hungarian, Hungary


id

public static final LocaleCode id
Indonesian


id_ID

public static final LocaleCode id_ID
Indonesian, Indonesia


is

public static final LocaleCode is
Icelandic


is_IS

public static final LocaleCode is_IS
Icelandic, Iceland


it

public static final LocaleCode it
Italian


it_CH

public static final LocaleCode it_CH
Italian, Switzerland


it_IT

public static final LocaleCode it_IT
Italian, Italy


ja

public static final LocaleCode ja
Japanese


ja_JP

public static final LocaleCode ja_JP
Japanese, Japan


ko

public static final LocaleCode ko
Korean


ko_KR

public static final LocaleCode ko_KR
Korean, Republic of Korea


lt

public static final LocaleCode lt
Lithuanian


lt_LT

public static final LocaleCode lt_LT
Lithuanian, Lithuania


lv

public static final LocaleCode lv
Latvian


lv_LV

public static final LocaleCode lv_LV
Latvian, Latvia


mk

public static final LocaleCode mk
Macedonian


mk_MK

public static final LocaleCode mk_MK
Macedonian, The former Yugoslav Republic of Macedonia


ms

public static final LocaleCode ms
Malay


ms_MY

public static final LocaleCode ms_MY
Malay, Malaysia


mt

public static final LocaleCode mt
Maltese


mt_MT

public static final LocaleCode mt_MT
Maltese, Malta


nl

public static final LocaleCode nl
Dutch


nl_BE

public static final LocaleCode nl_BE
Dutch, Belgium


nl_NL

public static final LocaleCode nl_NL
Dutch, Netherlands


nn_NO

public static final LocaleCode nn_NO
Norwegian Nynorsk, Norway


no

public static final LocaleCode no
Norwegian


no_NO

public static final LocaleCode no_NO
Norwegian, Norway


pl

public static final LocaleCode pl
Polish


pl_PL

public static final LocaleCode pl_PL
Polish, Poland


pt

public static final LocaleCode pt
Portuguese


pt_BR

public static final LocaleCode pt_BR
Portuguese, Brazil


pt_PT

public static final LocaleCode pt_PT
Portuguese, Portugal


ro

public static final LocaleCode ro
Romanian


ro_RO

public static final LocaleCode ro_RO
Romanian, Romania


ru

public static final LocaleCode ru
Russian


ru_RU

public static final LocaleCode ru_RU
Russian, Russian Federation


sk

public static final LocaleCode sk
Slovak


sk_SK

public static final LocaleCode sk_SK
Slovak, Slovakia


sl

public static final LocaleCode sl
Slovene


sl_SI

public static final LocaleCode sl_SI
Slovene, Slovenia


sq

public static final LocaleCode sq
Albanian


sq_AL

public static final LocaleCode sq_AL
Albanian, Albania


sr

public static final LocaleCode sr
Serbian


sr_BA

public static final LocaleCode sr_BA
Serbian, Bosnia and Herzegovina


sr_CS

public static final LocaleCode sr_CS
Serbian, Serbia and Montenegro


sr_ME

public static final LocaleCode sr_ME
Serbian, Montenegro


sr_RS

public static final LocaleCode sr_RS
Serbian, Serbia


sv

public static final LocaleCode sv
Swedish


sv_SE

public static final LocaleCode sv_SE
Swedish, Sweden


th

public static final LocaleCode th
Thai


th_TH

public static final LocaleCode th_TH
Thai, Thailand


tr

public static final LocaleCode tr
Turkish


tr_TR

public static final LocaleCode tr_TR
Turkish, Turkey


uk

public static final LocaleCode uk
Ukrainian


uk_UA

public static final LocaleCode uk_UA
Ukrainian, Ukraine


vi

public static final LocaleCode vi
Vietnamese


vi_VN

public static final LocaleCode vi_VN
Vietnamese, Viet Nam


zh

public static final LocaleCode zh
Chinese


zh_CN

public static final LocaleCode zh_CN
Chinese, China


zh_HK

public static final LocaleCode zh_HK
Chinese, Hong Kong


zh_SG

public static final LocaleCode zh_SG
Chinese, Singapore


zh_TW

public static final LocaleCode zh_TW
Chinese, Taiwan, Province of China

Method Detail

values

public static LocaleCode[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (LocaleCode c : LocaleCode.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static LocaleCode valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type has no constant with the specified name
NullPointerException - if the argument is null

getLanguage

public LanguageCode getLanguage()
Get the language code.

Returns:
The language code. This method always returns a non-null value.

getCountry

public CountryCode getCountry()
Get the country code.

Returns:
The country code. This method may return null. For example, LocaleCode.en.getCountry() returns null.

toString

public String toString()
Get the string representation of this locale code. Its format is either of the following:

where language is an ISO 639-1 code and country is an ISO 3166-1 alpha-2 code.

Overrides:
toString in class Enum<LocaleCode>
Returns:
The string representation of this locale code.

toLocale

public Locale toLocale()
Convert this LocaleCode instance to a Locale instance.

In most cases, this method creates a new Locale instance every time it is called, but some LocaleCode instancess return their corresponding entries in Locale class. For example, LocaleCode.it always returns Locale.ITALIAN.

The table below lists LocaleCode entries whose toLocale() do not create new Locale instances but return entries in Locale class.

LocaleCode Locale
LocaleCode.de Locale.GERMAN
LocaleCode.en Locale.ENGLISH
LocaleCode.fr Locale.FRENCH
LocaleCode.fr_CA Locale.CANADA_FRENCH
LocaleCode.it Locale.ITALIAN
LocaleCode.ja Locale.JAPANESE
LocaleCode.ko Locale.KOREAN
LocaleCode.zh Locale.CHINESE
LocaleCode.zh_CN Locale.SIMPLIFIED_CHINESE
LocaleCode.zh_TW Locale.TRADITIONAL_CHINESE

Returns:
A Locale instance that matches this LocaleCode.

getByCode

public static LocaleCode getByCode(String code)
Get a LocaleCode instance that corresponds to the given code.

This method just calls getByCode(code, false).

Parameters:
code - A locale code.
Returns:
A LocaleCode instance, or null if not found.
See Also:
getByCode(String, boolean)

getByCode

public static LocaleCode getByCode(String code,
                                   boolean caseSensitive)
Get a LocaleCode instance that corresponds to the given code.

The format of the code should be either of the following:

where language is an ISO 639-1 code and country is an ISO 3166-1 alpha-2 code. The separator between language and country should be a hyphen (-) or an underscore (_).

Note that if the language part of the given code is one of legacy ones { "iw", "ji" and "in" }, it is regarded as its newer official counterpart { "he", "yi" and "id", respectively }.

Parameters:
code - A locale code.
caseSensitive - If true, the language part of the given code must be lower-case and the country part, if not null, must be upper-case. If false, this method internally canonicalizes the given code and then performs search.
Returns:
A LocaleCode instance, or null if not found.

getByCode

public static LocaleCode getByCode(String language,
                                   String country)
Get a LocaleCode instance that corresponds to the given pair of language code and country code.

This method just calls getByCode(language, country, false).

Parameters:
language - ISO 639-1 language code. If the given language code is one of legacy ones { "iw", "ji" and "in" }, it is regarded as its newer official counterpart { "he", "yi" and "id", respectively }.
country - ISO 3166-1 alpha-2 country code.
Returns:
A LocaleCode, or null if not found.
See Also:
getByCode(String, String, boolean)

getByCode

public static LocaleCode getByCode(String language,
                                   String country,
                                   boolean caseSensitive)
Get a LocaleCode instance that corresponds to the given pair of language code and country code.

Parameters:
language - ISO 639-1 language code. If the given language code is one of legacy ones { "iw", "ji" and "in" }, it is regarded as its newer official counterpart { "he", "yi" and "id", respectively }.
country - ISO 3166-1 alpha-2 country code.
caseSensitive - If true, the given language code must be lower-case and the given country code, if not null, must be upper-case. If false, this method internally canonicalizes the given codes and then performs search.
Returns:
A LocaleCode, or null if not found.

getByLocale

public static LocaleCode getByLocale(Locale locale)
Get a LocaleCode instance that corresponds to the given Locale instance.

Parameters:
locale - A Locale instance.
Returns:
A LocaleCode instance, or null if not found.


Copyright © 2013. All Rights Reserved.