cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruno Dumon <br...@outerthought.org>
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 <sylvain@apache.org>:
> > 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
french:

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("",
              countries[i]).getDisplayCountry(targetLocale));
    }
  }
}

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
information.

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                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message