0

A simple example of date (day and month) translation. The code is for Welsh, but can be easily modified for any language - especially those without "full" support. I have used the code in a footer to display the last updated date and time.

//EDIT - a few years later
Please excuse this snippet - it was written when I was starting out and I thought that I could programme :(
There are many, many better ways of doing this.

Edited by diafol: Embarrassment

<?php
function english_to_welsh_date(){
    global $MyDay;
    global $MyMon;

    $day_array = array("Sunday" => "Dydd Sul", "Monday" => "Dydd Llun", "Tuesday" => "Dydd Mawrth", "Wednesday" => "Dydd Mercher", "Thursday" => "Dydd Iau", "Friday" => "Dydd Gwener", "Saturday" => "Dydd Sadwrn");

    $MyDay = $day_array[$MyDay];
    
    $mon_array = array("January" => "Ionawr", "February" => "Chwefror", "March" => "Mawrth", "April" => "Ebrill", "May" => "Mai", "June" => "Mehefin", "July" => "Gorffennaf", "August" => "Awst", "September" => "Medi", "October" => "Hydref", "November" => "Tachwedd", "December" => "Rhagfyr");

    $MyMon = $mon_array[$MyMon];
}


$MyDay = date("l", getlastmod());
$MyMon = date("F", getlastmod());

english_to_welsh_date();
	
$MyDate = "Cyfddyddiwyd: " . $MyDay . ", " . $MyMon . date (" d, Y", getlastmod()) . " am " . date("H:i:s.", getlastmod());

echo $MyDate;

//Displays:- Cyfdyddiwyd: Dydd Mawrth, Hydref 24, 2006 am 15:51:32. for Updated: Tuesday, October 24, 2006 at 15:51:32.
?>
2
Contributors
1
Reply
7
Views
11 Years
Discussion Span
Last Post by 42south
0

I have just registered to say 'This is great'!

With very little thinking required on my part, I have managed to successfully adapt it Te Reo (aka Maori)

Thanks!

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.