Listing All Available Locales

Locale[] locales = Locale.getAvailableLocales(); for (int i=0; i<locales.length; i++) { // Get the 2-letter language code String language = locales[i].getLanguage(); // Get the 2-letter country code; may be equal to "" String country = locales[i].getCountry(); // Get localized name suitable for display to the user String locName = locales[i].getDisplayName(); }
Here's a sample of output using a default locale of Locale.ENGLISH:
Language Code, Country Code, Localized Name 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)
Here's a sample of output using a default locale of Locale.FRENCH:
Language Code, Country Code, Localized Name ar, , arabe ar, AE, arabe (Emirats Arabes Unis) ar, EG, arabe (Egypte) ar, IQ, arabe (Irak) ar, JO, arabe (Jordanie) ar, KW, arabe (Koweit) ar, LB, arabe (Liban)

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.