Connecting Tech Pros Worldwide Help | Site Map

[5.2.5] Supporting European locales?

Gilles Ganault
Guest
 
Posts: n/a
#1: Mar 26 '08
Hello

What does it take to support locales? The following test code found on
the PHP site doesn't work as planned:

=======
setlocale(LC_TIME, "C");
echo strftime("%A");
setlocale(LC_TIME, "fi_FI");
echo strftime(" in Finnish is %A,");
setlocale(LC_TIME, "fr_FR");
echo strftime(" in French %A and");
setlocale(LC_TIME, "de_DE");
echo strftime(" in German %A.\n");
=======
Wednesday in Finnish is Wednesday, in French Wednesday and in German
Wednesday.
=======

I have a YYYY-MM-DD-formatted date in MySQL that I'd like to display
as "Weekday DD/MM/YYYY".

Do I need to recompile PHP or its extensions with a given switch, or
do I need some extra libraries in Linux?

Thank you.
Gilles Ganault
Guest
 
Posts: n/a
#2: Mar 26 '08

re: [5.2.5] Supporting European locales?


On Wed, 26 Mar 2008 20:39:04 +0100, Gilles Ganault <nospam@nospam.com>
wrote:
Quote:
>What does it take to support locales? The following test code found on
>the PHP site doesn't work as planned:
For those interested, here's what I found out, on a FreeBSD 6.3 host:

1. date() only uses the US locale, even if you call setlocale()
beforehand.

2. The following doesn't work:
setlocale (LC_ALL, "fr_FR");
setlocale (LC_TIME, "fr_FR");
setlocale (LC_ALL, "fr-FR");
setlocale (LC_TIME, "fr-FR");

3. The following works:

setlocale (LC_TIME, "fr_FR.ISO8859-1");
setlocale (LC_ALL, "fr_FR.ISO8859-1");
echo strftime("%a %d/%m/%Y",strtotime("2008-03-16"));

HTH,
Michael Fesser
Guest
 
Posts: n/a
#3: Mar 26 '08

re: [5.2.5] Supporting European locales?


..oO(Gilles Ganault)
Quote:
>On Wed, 26 Mar 2008 20:39:04 +0100, Gilles Ganault <nospam@nospam.com>
>wrote:
Quote:
>>What does it take to support locales? The following test code found on
>>the PHP site doesn't work as planned:
>
>For those interested, here's what I found out, on a FreeBSD 6.3 host:
>
>1. date() only uses the US locale, even if you call setlocale()
>beforehand.
Correct. For locale-dependent output you have to use strftime().
Quote:
>2. The following doesn't work:
>setlocale (LC_ALL, "fr_FR");
>setlocale (LC_TIME, "fr_FR");
>setlocale (LC_ALL, "fr-FR");
>setlocale (LC_TIME, "fr-FR");
>
>3. The following works:
>
>setlocale (LC_TIME, "fr_FR.ISO8859-1");
>setlocale (LC_ALL, "fr_FR.ISO8859-1");
>echo strftime("%a %d/%m/%Y",strtotime("2008-03-16"));
It always depends on which locales are installed on the system.

Micha
Gilles Ganault
Guest
 
Posts: n/a
#4: Mar 26 '08

re: [5.2.5] Supporting European locales?


On Wed, 26 Mar 2008 22:20:40 +0100, Michael Fesser <netizen@gmx.de>
wrote:
Quote:
>It always depends on which locales are installed on the system.
Right. Use "locale -a" to find what locales are installed.
AnrDaemon
Guest
 
Posts: n/a
#5: Jun 2 '08

re: [5.2.5] Supporting European locales?


Greetings, Gilles Ganault.
In reply to Your message dated Thursday, March 27, 2008, 02:26:52,
Quote:
Quote:
>>It always depends on which locales are installed on the system.
Quote:
Right. Use "locale -a" to find what locales are installed.
It is possible to access list of installed locales through PHP?
Or, alternatively, where to get such list for the Windows host?


--
Sincerely Yours, AnrDaemon <anrdaemon@freemail.ru>

Closed Thread