Forum Moderators: coopster
i have a site with an english and french version - i output the current date on the english one, but need to output the current date in french on the french version.
simple php is date("l F j, Y") for the date
is there a way i can do...
language("French");
echo date("l F j, Y");
?
Thanks in advance
you could build some arrays of the french names and then swap them.
also remember that your format you have there is actually wrong in french, you have to swap the month and day for french. I don't remember how they add day of the week, I don't remember seeing it much actually.
<added>as an aside, there is no fun or easy way to do internationalization, it sucks. I was sitting around with some fairly well known php folk a while back and that was our agreed on unanymous position 'it sucks'.
To serve up the date using PHP I find setlocale [php.net] to be a great tool. I've added a little trick to determine whether or not the server is a Windows server as well since the codes may be different depending on the server you are running and how you have it setup (what I mean is that 'french' could likely be used here for both but sometimes you'll have to check the locale files to be sure). Links to the codes are on the PHP setlocale page. Oh yeah, you can also get fancy by checking the $_SERVER['HTTP_ACCEPT_LANGUAGE'] or extension of the $_SERVER['SCRIPT_NAME'] if you have setup your site with multi documents per language.
if (stristr [php.net](PHP_OS [php.net], 'WIN')) {
setlocale [php.net](LC_ALL, 'fra');
} else {
setlocale [php.net](LC_ALL, 'french');
}
print strftime [php.net]('%A %B %j, %Y ');
?>
thats what i figured - 'it sucks'
for the nature of my project and timeline, i think i'm going to use the array method and swap english terms for french....yes, the date ordering needs to be change for french.
ill probably just make a modular method to drop into any php app to return the french formated date.
Thanks for your input on this...always appreciated