Missing Locales in Java?
Sun Java 6 only provides support for a limited subset of locales. The vector of support for formatting classes/writing systems/etc. is listed in the JDK documentation.
Now, I haven't done this, but...
You can plug in support for additional locales via the SPIs (described here). For example, to provide a date formatter for a new locale, you would do it by implementing a DateFormatProvider
service. You might be able to do this by decorating an existing implementation - I'd have a look at the ICU4J library to see if it provides the support you want.
there is no one-to-one mapping between countries in the world and the locales. Locales specify regions. They are meant to mark things like language diversity. Just a clarifying example : India, Sri Lanka, Pakistan , Bangladesh are all different countries..but the way they use the english language is not different in any significant way..its a demographic thing..so all these countries could depends on the indian locale
The static method Locale.getISOCountries()
returns all the two letter codes for countries in the ISO 3166 Countries list. If you run the code below:
String[] codes = Locale.getISOCountries();
for (String code : codes) {
System.out.println(code);
}
You will notice that PK (PAKISTAN), NG (NIGERIA) and KG (KYRGYZSTAN) are all in the list. Note this does not mean the locale associated with the country is installed. If you want to implement any locale specific behaviour the only locales supported are those returned by Locale.getAvailableLocales
.