Trill Designs: Translate Date Into Your Language - Trill Designs

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Translate Date Into Your Language

#1 User is offline   Jaan Icon

  • Site Admin
  • Icon
  • Group: Administrators
  • Posts: 85
  • Joined: 23-November 09
  • LocationEstonia

Posted 25 January 2010 - 09:16 PM

Hey!

Want to know how you can translate date into your language. It's really simple tho.. oki let's start.

First we have to define our day, month and year.

<?php
$day = date("l");
$daynum = date("j");
$month = date("M");
$year = date("Y");
?>


Now let's translate our days. I'm going to translate our date into estonian ^^

// If our day is Monday (For example) then it changes our day into Esmaspäev (Monday in estonian)
if($day == "Monday"){
$day = "Esmaspäev";
}elseif($day == "Tuesday"){
$day = "Teisipäev";
}elseif($day == "Wednesday"){
$day = "Kolmapäev";
}elseif($day == "Thursday"){
$day = "Neljapäev";
}elseif($day == "Friday"){
$day = "Reede";
}elseif($day == "Saturday"){
$day = "Laupäev";
}elseif($day == "Sunday"){
$day = "Pühapäev";
}


You should change those estonian words into your language ^^
Now let's translate our months..

// For example..if our month is January then it changes January into Jaanuar
if($month == "January"){
$month = "Jaanuar";
}elseif($month == "February"){
$month = "Veebruar";
}elseif($month == "March"){
$month = "Märts";
}elseif($month == "April"){
$month = "Aprill";
}elseif($month == "May"){
$month = "Mai";
}elseif($month == "June"){
$month = "Juuni";
}elseif($month == "July"){
$month = "Juuli";
}elseif($month == "August"){
$month = "August";
}elseif($month == "September"){
$month = "September";
}elseif($month == "October"){
$month = "Oktoober";
}elseif($month == "November"){
$month = "November";
}elseif($month == "December"){
$month = "Detsember";
}


And now let's display our date:

echo $daynum.". ", $month." ", $day." ", $year;


Simple eh.. :D okay here's the full script:

<?php
$day = date("l");
$daynum = date("j");
$month = date("M");
$year = date("Y");

if($day == "Monday"){
$day = "Esmaspäev";
}elseif($day == "Tuesday"){
$day = "Teisipäev";
}elseif($day == "Wednesday"){
$day = "Kolmapäev";
}elseif($day == "Thursday"){
$day = "Neljapäev";
}elseif($day == "Friday"){
$day = "Reede";
}elseif($day == "Saturday"){
$day = "Laupäev";
}elseif($day == "Sunday"){
$day = "Pühapäev";
}

if($month == "January"){
$month = "Jaanuar";
}elseif($month == "February"){
$month = "Veebruar";
}elseif($month == "March"){
$month = "Märts";
}elseif($month == "April"){
$month = "Aprill";
}elseif($month == "May"){
$month = "Mai";
}elseif($month == "June"){
$month = "Juuni";
}elseif($month == "July"){
$month = "Juuli";
}elseif($month == "August"){
$month = "August";
}elseif($month == "September"){
$month = "September";
}elseif($month == "October"){
$month = "Oktoober";
}elseif($month == "November"){
$month = "November";
}elseif($month == "December"){
$month = "Detsember";
}

echo $daynum.". ", $month." ", $day." ", $year;
?>



Have fun!
Jaan
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users