![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e335. Listing All Available LocalesLocale[] 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)
e332. Breaking a String into Words e333. Creating a Custom Event e334. Implementing a Simple Event Notifier e336. Setting the Default Locale e337. Associating a Value with an Object
© 2002 Addison-Wesley. |