develooper Front page | perl.i18n | Postings from May 2006

Re: Perl, setlocale and Apache

Thread Previous
Claude Paroz
May 15, 2006 12:46
Re: Perl, setlocale and Apache
Message ID:
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, 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/, 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 ...).



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