using setlocale

Problems with the Windows version of XAMPP, questions, comments, and anything related.

using setlocale

Postby torvista » 27. July 2009 04:27

Hi,
I am developing an english/spanish zencart on a windows 2000 local pc with xampp.

Some of the generated text in the cart uses strftime to get the day and month names in the correct language.
This works ok on my unix host but not on the xampp server.

I have used this code for testing the installed locales:

Code: Select all
<?php
echo "<hr><br>The available 'locale' strings for 'es' on this server are:<br>";
echo '<pre>';
system('locale -a | grep -i es');
echo '</pre>';
?>


When I run this on my unix host, it returns a nice long list including es_ES.utf8 which I have been using in setlocale successfully.

When run locally on the xampp windows 2000 machine it returns nothing, not with es, esp, spain or en, only the first line of the test:

The available 'locale' strings for 'en' on this server are:

Due to lack of knowledge I don’t know if I should be installing or enabling something on the server or maybe (more likely) it is not executing the system command, anyway after a LOT of searching I have to admit defeat and ask here, what is going on?

Thanks
Steve
torvista
 
Posts: 8
Joined: 27. July 2009 04:15

Re: using setlocale

Postby Wiedmann » 27. July 2009 06:45

There is no command "locale" (and "grep") on Windows which you can execute with system().
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: using setlocale

Postby torvista » 27. July 2009 14:27

Thanks for the reply, which brings me back to the original issue.

This works on my UNIX hosting server
Code: Select all
setlocale(LC_TIME, 'es_ES.UTF8');

but not on my local windows xampp server, to get the days and months output in spanish.

My first post was as a result of trying to determine the locales that are installed with xampp as I have no idea how to find out why this does not work.
So thats my problem,

thanks
Steve
torvista
 
Posts: 8
Joined: 27. July 2009 04:15

Re: using setlocale

Postby Wiedmann » 27. July 2009 14:34

My first post was as a result of trying to determine the locales that are installed with xampp as I have no idea how to find out why this does not work.

A locale with the name "es_ES.UTF8" does not exists on Windows. Maybe you want read the PHP manual page for setlocale() more carefully?
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: using setlocale

Postby torvista » 27. July 2009 16:17

Hi,
using this test gave me the information I was looking for

Code: Select all
<?php
echo '<hr>test WINDOWS server for locales';

/* try different possible locale names for english GB as of PHP 4.3.0 */
echo '<p>';
$loc_en = setlocale(LC_ALL, 'english_gbr', 'english_britain', 'english_england', 'english_great britain', 'english_uk', 'english_united kingdom', 'english_united-kingdom');
echo "Preferred locale for english GB on this system is '$loc_en'";
echo '<br/>' . strftime("%A %d %B %Y", mktime(0, 0, 0, 12, 22, 1978));

/* try different possible locale names for english USA as of PHP 4.3.0 */
echo '<p>';
$loc_enusa = setlocale(LC_ALL, 'english_usa', 'english_america', 'english_united states', 'english_united-states', 'english_us');
echo "Preferred locale for english USA on this system is '$loc_enusa'";
echo '<br/>' . strftime("%A %d %B %Y", mktime(0, 0, 0, 12, 22, 1978));

/* try different possible locale names for german as of PHP 4.3.0 */
echo '<p>';
$loc_de = setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'deu_deu');
echo "Preferred locale for german on this system is '$loc_de'";
echo '<br/>' . strftime("%A %d %B %Y", mktime(0, 0, 0, 12, 22, 1978));

/* try different possible locale names for spanish as of PHP 4.3.0 */
echo '<p>';
$loc_es = setlocale(LC_ALL, 'esp_esp', 'esp_spain', 'spanish_esp', 'spanish_spain');
echo "Preferred locale for spanish on this system is '$loc_es'";
echo '<br/>' . strftime("%A %d %B %Y", mktime(0, 0, 0, 12, 22, 1978));

/* try different possible locale names for dutch as of PHP 4.3.0 */
echo '<p>';
$loc_nl = setlocale(LC_ALL, 'nld_nld');
echo "Preferred locale for dutch on this system is '$loc_nl'";
echo '<br/>' . strftime("%A %d %B %Y", mktime(0, 0, 0, 12, 22, 1978));
?>


and what came out :
test WINDOWS server for locales

Preferred locale for english GB on this system is 'English_United Kingdom.1252'
Friday 22 December 1978

Preferred locale for english USA on this system is 'English_United States.1252'
Friday 22 December 1978

Preferred locale for german on this system is 'German_Germany.1252'
Freitag 22 Dezember 1978

Preferred locale for spanish on this system is 'Spanish_Spain.1252'
viernes 22 diciembre 1978

Preferred locale for dutch on this system is 'Dutch_Netherlands.1252'
vrijdag 22 december 1978
torvista
 
Posts: 8
Joined: 27. July 2009 04:15


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 73 guests