cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruno Dumon <>
Subject Re: Sharing is caring... selection-list for country codes?
Date Sun, 06 Nov 2005 08:36:22 GMT
On Sat, 2005-11-05 at 15:53 +0100, Antonio Fiol BonnĂ­n wrote:
> 2005/10/11, Sylvain Wallez <>:
> > Mark Lundquist wrote:
> > > I need an XML file with an <fd:selection-list> full of country name =>
> > > ISO country codes...
> > >
> > > So, who's got one? :-)
> >
> > If you have one, I'll happily include it in the Cocoon forms jar, so
> > that you could write
> > <fd:selection-list
> > src="resource://org/apache/cocoon/forms/system/util/country-codes.xml"/>
> What would be the Right(tm) approach for internationalized country names?

It is possible to retrieve this information using the java.util.Locale
class, for example, here's a short program to list the countries in

import java.util.Locale;

public class Countries {
  public static void main(String[] args) {
    Locale targetLocale = new Locale("fr");
    String[] countries = Locale.getISOCountries();
    for (int i = 0; i < countries.length; i++) {
      System.out.println(new Locale("",

However, from what I see, far from all country names are translated into
all languages (probably only the country names where those languages are
actually spoken).

While at it, I've tried the same using the ULocale class from the icu4j
library, which does seem to contain much more (or complete?) localized

So a good approach would be to have a selection list implementation that
tests if the ULocale class is available and otherwise falls back to the
Locale class. Some other things to take care of are sorting the country
names alphabetically and possibly some caching if needed. Alternatively,
we could once run a program which pre-generates selection list data for
all desired languages.

Bruno Dumon                   
Outerthought - Open Source, Java & XML Competence Support Center                

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message