php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22596 Setlocale(LC_ALL,"swedish") does not work
Submitted: 2003-03-07 18:34 UTC Modified: 2003-03-08 11:03 UTC
From: mats2 at nerdlabs dot org Assigned:
Status: Closed Package: Gettext related
PHP Version: 4.3.0 OS: Linux, Debian 3.0
Private report: No CVE-ID: None
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
28 + 36 = ?
Subscribe to this entry?

 
 [2003-03-07 18:34 UTC] mats2 at nerdlabs dot org
Running php 4.3.0/apache 1.3.27 on debian 3.0 (php & apache downloaded and compiled from non-debian sources) I've run into a problem with setlocale().

After a few hours trying to use gettext() to add swedish support to a site i discovered that the combination LC_ALL and sv_SE/swedish for setlocale() does not work. Almost all other combinations of LC_'s and languages I've tried works as expected. 

This short test script:

<?php
echo "LC_MESSAGES,swedish = ".setlocale(LC_MESSAGES,"swedish")."<br>";
echo "LC_MESSAGES,sv_SE = ".setlocale(LC_MESSAGES,"sv_SE")."<br>";
echo "LC_MESSAGES,danish = ".setlocale(LC_MESSAGES,"danish")."<br>";

echo "LC_ALL,swedish = ".setlocale(LC_ALL,"swedish")."<br>";
echo "LC_ALL,sv_SE = ".setlocale(LC_ALL,"sv_SE")."<br>";
echo "LC_ALL,danish = ".setlocale(LC_ALL,"danish")."<br>";

echo "LC_NUMERIC,swedish = ".setlocale(LC_NUMERIC,"swedish")."<br>";
echo "LC_NUMERIC,sv_SE = ".setlocale(LC_NUMERIC,"sv_SE")."<br>";
echo "LC_NUMERIC,danish = ".setlocale(LC_NUMERIC,"danish")."<br>";
?>

Returns the followning result:

LC_MESSAGES,swedish = swedish
LC_MESSAGES,sv_SE = sv_SE
LC_MESSAGES,danish = danish
LC_ALL,swedish = 
LC_ALL,sv_SE = 
LC_ALL,danish = danish
LC_NUMERIC,swedish = swedish
LC_NUMERIC,sv_SE = sv_SE
LC_NUMERIC,danish = danish


The config line is:

./configure \
--with-mysql \
--with-apxs=/usr/local/sbin/apxs \
--with-config-file-path=/etc/apache \
--enable-safe-mode \
--with-gettext=/usr/bin \
--with-exec-dir \
--with-xml \
--with-bz2 \
--with-zlib \
--with-gd \
--with-exif \
--with-jpeg-dir=/usr/lib \
--with-png-dir=/usr/lib \
--with-ttf \
--enable-gd-native-ttf 

I've generated _ALL_ locales available on the system.

/Mats

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-03-08 10:11 UTC] mats2 at nerdlabs dot org
Running the same test using C instead of PHP then LC_ALL combined with Swedish gives the correct result:

#include <stdio.h>
#include <locale.h>
       
int main(int argc, char *argv[]) {
 printf("LC_MESSAGES,swedish = %s\n",setlocale(LC_MESSAGES,"swedish"));
 printf("LC_MESSAGES,sv_SE = %s\n",setlocale(LC_MESSAGES,"sv_SE"));
 printf("LC_MESSAGES,danish = %s\n",setlocale(LC_MESSAGES,"danish"));

 printf("LC_ALL,swedish = %s\n",setlocale(LC_ALL,"swedish"));
 printf("LC_ALL,sv_SE = %s\n",setlocale(LC_ALL,"sv_SE"));
 printf("LC_ALL,danish = %s\n",setlocale(LC_ALL,"danish"));

 printf("LC_NUMERIC,swedish = %s\n",setlocale(LC_NUMERIC,"swedish"));
 printf("LC_NUMERIC,sv_SE = %s\n",setlocale(LC_NUMERIC,"sv_SE"));
 printf("LC_NUMERIC,danish = %s\n",setlocale(LC_NUMERIC,"danish"));

 return 1;
}



LC_MESSAGES,swedish = swedish
LC_MESSAGES,sv_SE = sv_SE
LC_MESSAGES,danish = danish
LC_ALL,swedish = swedish
LC_ALL,sv_SE = sv_SE
LC_ALL,danish = danish
LC_NUMERIC,swedish = swedish
LC_NUMERIC,sv_SE = sv_SE
LC_NUMERIC,danish = danish

/Mats
 [2003-03-08 11:03 UTC] sniper@php.net
Works fine with PHP 4.3.2-dev (latest stable snapshot).

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 10 02:01:26 2024 UTC