Days of week in other language !!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
liviu
Forum Newbie
Posts: 16
Joined: Fri Jul 18, 2003 6:39 pm
Location: Tulcea, Romania

Days of week in other language !!

Post by liviu »

Hy, can someone help me with this problem ?
I whant to show on my site the name of the days in a week (Monday etc.) in my own language (romanian). Right now i get this by using the date() function. Can i translate the output of this function ? :?:

Thanks in advance...
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

You could try using setlocale().
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

Code: Select all

<?php
/*
to translate a date on a another language use this function (this example translates days and months on Polish- niedziela,poniedzialek...styczen,luty...):

Author: Peter Skalecki
http://www.petersoft.prv.pl
petersoft@wp.pl
Use:
print(DataPL("l, j F Y, G:i:s"));
*/
Function DataPL( $TwojaData )
{
$dzien[0] = "Niedziela";
$dzien[1] = "Poniedzialek";
$dzien[2] = "Wtorek";
$dzien[3] = "Sroda";
$dzien[4] = "Czwartek";
$dzien[5] = "Piatek";
$dzien[6] = "Sobota";

$miesiac[1] = "Styczen";
$miesiac[2] = "Luty";
$miesiac[3] = "Marzec";
$miesiac[4] = "Kwiecien";
$miesiac[5] = "Maj";
$miesiac[6] = "Czerwiec";
$miesiac[7] = "Lipiec";
$miesiac[8] = "Sierpien";
$miesiac[9] = "Wrzesien";
$miesiac[10] = "Pazdziernik";
$miesiac[11] = "Listopad";
$miesiac[12] = "Grudzien";

$TwojaData = str_replace( "l", "|.|.|", $TwojaData);
$TwojaData = str_replace( "F", "|,|,|", $TwojaData);
$TwojaData = date($TwojaData);
$TwojaData = str_replace( "|.|.|", $dzien[date("w")], $TwojaData);
$TwojaData = str_replace( "|,|,|", $miesiac[date("n")], $TwojaData);
return($TwojaData);}
?>
you can find lots of things..only if you read the php manual :P
liviu
Forum Newbie
Posts: 16
Joined: Fri Jul 18, 2003 6:39 pm
Location: Tulcea, Romania

Post by liviu »

Thanks, i realy could not find this kind of information on PHP Manual, or... i did not look where i should.... :oops:
Post Reply