Re: Perl, setlocale and Apache
[email protected] (Claude Paroz) Mon, 15 May 2006 21:46:13 +0200
| Newsgroups | perl.i18n |
|---|---|
| Message-ID | <[email protected]> |
Le samedi 13 mai 2006 à 23:02 +0200, Claude Paroz a écrit :
> Hi,
>
> I'm trying to localise some web pages written with Perl scripts.
> Here is a sample script I'm using to test :
>
> #!/usr/bin/perl
> use CGI qw(:all);
> use Locale::gettext;
> use POSIX;
>
> POSIX::setlocale(LC_MESSAGES, "fr");
> textdomain "libc";
>
> my $q = new CGI;
> print $q->header;
> print $q->start_html(-title=>"Admin Login");
> print $q->p(gettext("write incomplete"));
> print $q->end_html;
>
> If I run the script in the command line (perl test.pl), I'm getting the
> message in French ("write incomplete" -> "écriture incomplète").
>
> When I run the same script through my local Apache server
> (http://localhost/cgi-bin/test.pl), the message is always in English, as
> if the setlocale command had no effect.
>
> Is there a solution ?
Mmmh... Seems like Apache is more strict about the syntax of the
setlocale parameter. I had to provide the ll_CC syntax (fr_FR,
en_US, ...) of an existing ISO8859-1 locale on my system to make it
work. If I want to use UTF-8, I even have to tell explicitly :
fr_FR.utf8 ...).
Regards.
Claude