my example should also work with fr or fr-ca what do you get with: echo $_SERVER["HTTP_ACCEPT_LANGUAGE"]; ?
the locale-string depends on your webserver. under linux you have to build them first (e.g.: locale-gen)
take a look at the user-notes under http://ch2.php.net/manual/de/function.setlocale.php
g. martin luethi
Mon, 26 Jan 2004 14:36:04 -0500 John Taylor-Johnston <[EMAIL PROTECTED]>:
I see what you are doing, But don't see where to create fr or fr-ca, for my example?
John
Martin Luethi wrote:
the variable $_SERVER["HTTP_ACCEPT_LANGUAGE"] contains the Accept-Language- Header from the browser -> http://ch2.php.net/reserved.variables
with setlocale() you can set locale-informations -> http://ch2.php.net/function.setlocale
finally strftime() formats a date with the current locale-informations -> http://ch2.php.net/manual/en/function.strftime.php
sample script:
<?
if (preg_match("/^([a-z]{2}).([a-z]{2})$/i", $_SERVER["HTTP_ACCEPT_LANGUAGE"],
$m='')) { // e.g. de-ch
$locales[] = strtolower($m[1])."_".strtoupper($m[2]); // e.g. de_CH
$locales[] = strtolower($m[1]); // e.g. de
setlocale(LC_TIME, $locales);
} else if (preg_match("/^([a-z]{2})$/i", $_SERVER["HTTP_ACCEPT_LANGUAGE"],
$m='')) { // e.g. de
$locales[] = strtolower($m[1])."_".strtoupper($m[1]); // e.g. de_DE
$locales[] = strtolower($m[1]); // e.g. de
setlocale(LC_TIME, $locales);
}
echo strftime("%B", strtotime("+1 month"));
?>
g. martin luethi
Mon, 26 Jan 2004 03:29:16 -0500 John Taylor-Johnston <[EMAIL PROTECTED]>:
> Thanks!! :) Getting tired at this hour. > > Is there a way to detect the language of the browser and echo the > name of the month in that language? > >> <?= date("F", strtotime("+1 month")); ?>
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php