473,395 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

[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.
Mar 26 '08 #1
4 1782
On Wed, 26 Mar 2008 20:39:04 +0100, Gilles Ganault <no****@nospam.com>
wrote:
>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,
Mar 26 '08 #2
..oO(Gilles Ganault)
>On Wed, 26 Mar 2008 20:39:04 +0100, Gilles Ganault <no****@nospam.com>
wrote:
>>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().
>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
Mar 26 '08 #3
On Wed, 26 Mar 2008 22:20:40 +0100, Michael Fesser <ne*****@gmx.de>
wrote:
>It always depends on which locales are installed on the system.
Right. Use "locale -a" to find what locales are installed.
Mar 26 '08 #4
Greetings, Gilles Ganault.
In reply to Your message dated Thursday, March 27, 2008, 02:26:52,
>>It always depends on which locales are installed on the system.
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 <an*******@freemail.ru>

Jun 2 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: kaptain kernel | last post by:
I'm implementing a simple credit card number check on my website, in order to trap user errors. it doesn't validate with the bank, but validates against certain known rules (e.g. Amex always begins...
3
by: Ellen Herzfeld | last post by:
I have been tearing my hair out trying to get Python to sort strings containing accented characters according to the French locale settings on Mac OS X (10.3). I think I've done it correctly...
2
by: garykpdx | last post by:
Is there some sort of tutorial on locales or the locale module? I can't seem to find a list showing all possible locales. I made 'en' work alright, but when I tried 'de' or 'de_DE' or 'es_ES',...
3
by: J Trauntvein | last post by:
I was working with a co-worker the other day to work through the process of formatting numeric values by imbueing C++ iostreams with locales. His program's initialisation code had a call to...
3
by: Joshua Stewart | last post by:
Hi, I am trying to characterise a problem I am seeing on our C#/C++ xml driven application. We have recently added some basic Spanish language support to our application, but it seems that there...
8
by: Rik | last post by:
Hi all, is there a in PHP to get the available locales without shellacces (i.e. locale -a)? Grtz, -- Rik Wasmus
2
by: Adrian | last post by:
Hi All, Is there anyway to change what isspace thinks is a space character. I am parsing some log files and it would be nice to just read a field as what ever is between quotes or between 's ie...
399
by: =?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?= | last post by:
PEP 1 specifies that PEP authors need to collect feedback from the community. As the author of PEP 3131, I'd like to encourage comments to the PEP included below, either here (comp.lang.python), or...
0
by: robtyketto | last post by:
I will try to explain this as clearly as possible, here goes:- I'm working on an university assignment to design an electronic proof of delivery document for a firm which has customers over...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.