develooper Front page | perl.i18n | Postings from July 2007

Re: [perl-i18n] Perl locale information sources for server apps,and the CLDR

Thread Previous | Thread Next
Guido Flohr
July 2, 2007 08:53
Re: [perl-i18n] Perl locale information sources for server apps,and the CLDR
Message ID:

John ORourke wrote:
> I looked into the following:
>    - POSIX - great idea, but info seems incomplete (eg. quote style, 
> units of weight), and updates depend on your *nix distro.  Also dates 
> back to desktop days - the locale is set for a whole process, not ideal 
> in a web server environment.  Speed of locale switching seems OK though.

The most important point of POSIX::setlocale() is that it changes 
behaviors of existing functions.  Error messages ($!) are automatically 
localized, provided that the system supports the selected locale.  When 
you output floating point numbers, the correct floating point format 
will be chosen.

Your CLDR idea is maybe not the worst, but then actually Perl should be 
changed internally to use CLDR data, and ignore the OS hints.  However, 
for some topics like error messages this is not really possible.

Usually, the following approach works quite good for web applications or 
server applications in general:

1) On startup try to guess a locale setting and change the locale using 

2) Let Perl (resp. the underlying libc) do the work for the categories 
where this is already possible (OS error messages, decimal number 
formats, collating, and so on).

3) If you need more locale specific data, simply integrate them in your 
applications message catalogs for the specific locale, see 
Locale::Maketex or Locale::TextDomain for details.

If 3) doesn't seem clean to you: Generate the message catalogs, resp. 
the relevant part of the files from CLDR data.

Imperia AG, Development
Leyboldstr. 10 - D-50354 Hürth -

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About