ID: 22596 User updated by: mats2 at nerdlabs dot org Reported By: mats2 at nerdlabs dot org Status: Open Bug Type: Gettext related Operating System: Linux, Debian 3.0 PHP Version: 4.3.0 New Comment:
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 Previous Comments: ------------------------------------------------------------------------ [2003-03-07 18:34:51] 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 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=22596&edit=1