Lost Password?


  #1 (permalink)  
Old 05-29-2007, 04:38 PM
Jaan's Avatar   
Jaan Jaan is offline
Mod
 
Join Date: Dec 2006
Location: Estonia
Age: 17
Posts: 937
Last Blog:
AdStar Ad Control Pa...
Rep Power: 17
Jaan is just really niceJaan is just really niceJaan is just really niceJaan is just really nice
Send a message via MSN to Jaan
Default Translate date into your language

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 Code:
<?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 ^^

PHP Code:
// 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..

PHP Code:
// 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:

PHP Code:
echo $daynum.". "$month." "$day." "$year
Simple eh.. okay here's the full script:

PHP Code:
<?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
__________________


Cheap & Professional Web Design | Need help? Send a PM

Last edited by Jaan; 10-06-2007 at 08:36 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 05-31-2007, 11:23 AM
Jordan's Avatar   
Jordan Jordan is online now
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 9,666
Last Blog:
PHP Objects, Patterns,...
Rep Power: 20
Jordan is just really niceJordan is just really niceJordan is just really niceJordan is just really nice
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default

Nice tutorial, thanks for the post Jaan.
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog
The CodeCall Wiki is now fully integrated with vBulletin users! Check it out and add some new pages!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-31-2007, 11:39 AM
v0id's Avatar   
v0id v0id is online now
Retired
 
Join Date: Apr 2007
Location: Denmark
Posts: 2,654
Last Blog:
CherryPy(thon)
Rep Power: 29
v0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of light
Send a message via MSN to v0id
Default

I would prefer using a switch-statement, instead of if-statements.
It's in my opinion cleaner, and neater - but it's all about taste.
The result is the same, using any of them.

I've made a danish version, using a switch-statement, just to show how it could look like:
Code:
<?php
$day    = date("l");
$daynum = date("j");
$month  = date("M");
$year   = date("Y");

switch($day)
{
	case "Monday":    $day = "Mandag";  break;
	case "Tuesday":   $day = "Tirsdag"; break;
	case "Wednesday": $day = "Onsdag";  break;
	case "Thursday":  $day = "Torsdag"; break;
	case "Friday":    $day = "Fredag";  break;
	case "Saturday":  $day = "Lørdag";  break;
	case "Sunday":    $day = "Søndag";  break;
	default:          $day = "Unknown"; break;
}

switch($month)
{
	case "January":   $month = "Januar";    break;
	case "February":  $month = "Februar";   break;
	case "March":     $month = "Marts";     break;
	case "April":     $month = "April";     break;
	case "May":       $month = "Maj";       break;
	case "June":      $month = "Juni";      break;
	case "July":      $month = "Juli";      break;
	case "August":    $month = "August";    break;
	case "September": $month = "September"; break;
	case "October":   $month = "Oktober";   break;
	case "November":  $month = "November";  break;
	case "December":  $month = "December";  break;
	default:          $month = "Unknown";   break;
}

echo $day . " den " . $daynum . ". " . $month . ", " . $year;
?>
Anyways, nice job, Jaan!
__________________
05-03-2007 - 11-13-2008
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-31-2007, 01:01 PM
Jaan's Avatar   
Jaan Jaan is offline
Mod
 
Join Date: Dec 2006
Location: Estonia
Age: 17
Posts: 937
Last Blog:
AdStar Ad Control Pa...
Rep Power: 17
Jaan is just really niceJaan is just really niceJaan is just really niceJaan is just really nice
Send a message via MSN to Jaan
Default

thank you
__________________


Cheap & Professional Web Design | Need help? Send a PM
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 05-31-2007, 07:19 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,478
Last Blog:
Joomla! And Incompeten...
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default

Quote:
Originally Posted by v0id View Post
I would prefer using a switch-statement, instead of if-statements.
Thats the exact same thing I told him but either way works
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 06-01-2007, 06:23 PM
Jaan's Avatar   
Jaan Jaan is offline
Mod
 
Join Date: Dec 2006
Location: Estonia
Age: 17
Posts: 937
Last Blog:
AdStar Ad Control Pa...
Rep Power: 17
Jaan is just really niceJaan is just really niceJaan is just really niceJaan is just really nice
Send a message via MSN to Jaan
Default

yes you did.. ^^ but still.. i like elseif thingy
__________________


Cheap & Professional Web Design | Need help? Send a PM
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
new C-like programming language kenna Software Development Tools 14 09-03-2008 03:34 PM
Date in Oracle 8 Ronin Database & Database Programming 6 08-17-2007 01:25 AM
D Programming Language. R-G General Programming 2 04-12-2007 12:22 PM
PHP:Tutorial The Date John PHP Tutorials 0 01-10-2007 07:10 PM
What language to Learn? mevets General Programming 20 12-20-2006 10:04 AM


All times are GMT -5. The time now is 08:52 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads