Connecting Tech Pros Worldwide Help | Site Map

[5.2.5] Supporting European locales?

 
LinkBack Thread Tools Search this Thread
  #1  
Old March 26th, 2008, 07:45 PM
Gilles Ganault
Guest
 
Posts: n/a
Default [5.2.5] Supporting European locales?

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.

  #2  
Old March 26th, 2008, 09:05 PM
Gilles Ganault
Guest
 
Posts: n/a
Default 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,
  #3  
Old March 26th, 2008, 09:25 PM
Michael Fesser
Guest
 
Posts: n/a
Default 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
  #4  
Old March 26th, 2008, 10:35 PM
Gilles Ganault
Guest
 
Posts: n/a
Default 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.
  #5  
Old June 2nd, 2008, 10:34 AM
AnrDaemon
Guest
 
Posts: n/a
Default 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>

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.