|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 02:00:01 2025 UTC |
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