No translation on date format

General questions regarding the use of languages and encoding issues in Joomla! 1.0.x. Multi-lingual site solutions can be discussed in the child board. Translation discussions are now separate and can be found in the Working Groups Area.
Locked
User avatar
cis3038
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Sun Apr 09, 2006 4:20 pm

No translation on date format

Post by cis3038 » Tue Oct 17, 2006 1:57 pm

I'm using Danish language on my frontend, but the date formats are still in English.
How do I translate or change this?

Please help!

Thanks!
Christian

User avatar
JanV
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Mon Nov 28, 2005 3:53 pm
Location: NL- Veldhoven
Contact:

Re: No translation on date format

Post by JanV » Fri Oct 20, 2006 4:17 pm

look in Site-Global Configuration-Locale-Contryn Locale
There you will find the format; in my case nl_NL
so da_DK will  work for you and you get fredag, 20 oktober 2006

Parameters:
language - lowercase two-letter ISO-639 code. next underscore and
country - uppercase two-letter ISO-3166 code.

da_DK

You may want to download the complete Country Locale Settings from http://www.janvaane.com/public/joomla
Regards
Jan

ame268
Joomla! Apprentice
Joomla! Apprentice
Posts: 15
Joined: Tue Feb 20, 2007 2:44 pm

Re: No translation on date format

Post by ame268 » Sun Jan 27, 2008 2:00 pm

You can modify joomla.php, find function mosFormatDate and replace into this code :
/**
* Returns formated date according to current local and adds time offset
* @param string date in datetime format
* @param string format optional format for strftime
* @param offset time offset if different than global one
* @returns formated date
*/
function mosFormatDate( $date, $format="", $offset=NULL ){
global $mosConfig_offset;
if ( $format == '' ) {
// %Y-%m-%d %H:%M:%S
$format = _DATE_FORMAT_LC;
}
if ( is_null($offset) ) {
$offset = $mosConfig_offset;
}
if ( $date && ereg( "([0-9]{4})-([0-9]{2})-([0-9]{2})[ ]([0-9]{2}):([0-9]{2}):([0-9]{2})", $date, $regs ) ) {
$date = mktime( $regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1] );
$date = $date > -1 ? strftime( $format, $date + ($offset*60*60) ) : '-';
}

$new = explode(",","$date");
  // New Day
  $Newday = $new[0];

  $new = explode(" ","$date");
  // New Date
  $Newdate = $new[1];
  // New Mouth
  $Newmounth = $new[2];
  $NewYear = $new[3];

//for days in bengali
  if($Newday == "Monday")
      $Newday = "Your Language Day";
  else if($Newday == "Tuesday")
      $Newday = "Your Language Day";
  else if($Newday == "Wednesday")
      $Newday = "Your Language Day";
  else if($Newday == "Thursday")
      $Newday = "Your Language Day";
  else if($Newday == "Friday")
      $Newday = "Your Language Day";
  else if($Newday == "Saturday")
      $Newday = "Your Language Day";
  else if($Newday == "Sunday")
      $Newday = "Your Language Day";

  if($Newmounth == "January")
      $Newmounth = "Your Language Day";
  else if($Newmounth == "February")
      $Newmounth = "Your Language Month";
  else if($Newmounth == "March")
      $Newmounth = "Your Language Month";
  else if($Newmounth == "April")
      $Newmounth = "Your Language Month";
  else if($Newmounth == "May")
      $Newmounth = "Your Language Month";
  else if($Newmounth == "June")
      $Newmounth = "Your Language Month";
  else if($Newmounth == "July")
      $Newmounth = "Your Language Month";
  else if($Newmounth == "August")
      $Newmounth = "Your Language Month";
  else if($Newmounth == "September")
      $Newmounth = "Your Language Month";
  else if($Newmounth == "October")
      $Newmounth = "Your Language Month";
  else if($Newmounth == "November")
      $Newmounth = "Your Language Month";
  else if($Newmounth == "December")
      $Newmounth = "Your Language Month";


  $date = $Newday.", ".$Newdate." ".$Newmounth." ".$NewYear;


return $date;
}

/**
Change to your language day or month.

User avatar
Georges Calvo
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Fri Jul 11, 2008 7:47 am
Location: France

Re: No translation on date format

Post by Georges Calvo » Fri Jul 11, 2008 8:03 am

Hello ame268 and thank you very much for your good help!
For a multilingual site I adapted your code to receive the infos various languages ("french.php","english.php",...etc).
Super... but there a small problem, I do not manage to translate the months... would you have a suggestion?
function mosFormatDate( $date, $format="", $offset=NULL ){
global $mosConfig_offset;
if ( $format == '' ) {
// %Y-%m-%d %H:%M:%S
$format = _DATE_FORMAT_LC;
}
if ( is_null($offset) ) {
$offset = $mosConfig_offset;
}
if ( $date && ereg( "([0-9]{4})-([0-9]{2})-([0-9]{2})[ ]([0-9]{2}):([0-9]{2}):([0-9]{2})", $date, $regs ) ) {
$date = mktime( $regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1] );
$date = $date > -1 ? strftime( $format, $date + ($offset*60*60) ) : '-';
}
$new = explode(",","$date");
// New Day
$Newday = $new[0];

$new = explode(" ","$date");
// New Date
$Newdate = $new[1];
// New Mouth
$Newmounth = $new[2];
$NewYear = $new[3];

//for days in bengali
if($Newday == "Monday")
$Newday = _MONDAY;
else if($Newday == "Tuesday")
$Newday = _TUESDAY;
else if($Newday == "Wednesday")
$Newday = _WEDNESDAY;
else if($Newday == "Thursday")
$Newday = _THURSDAY;
else if($Newday == "Friday")
$Newday = _FRIDAY;
else if($Newday == "Saturday")
$Newday = _SATURDAY;
else if($Newday == "Sunday")
$Newday = _SUNDAY;

if($Newmounth == "January")
$Newmounth = _JANUARY;
else if($Newmounth == "February")
$Newmounth = _FEBRUARY;
else if($Newmounth == "March")
$Newmounth = _MARCH;
else if($Newmounth == "April")
$Newmounth = _APRIL;
else if($Newmounth == "May")
$Newmounth = _MAY;
else if($Newmounth == "June")
$Newmounth = _JUNE;
else if($Newmounth == "July")
$Newmounth = _JULY;
else if($Newmounth == "August")
$Newmounth = _AUGUST;
else if($Newmounth == "September")
$Newmounth = _SEPTEMBER;
else if($Newmounth == "October")
$Newmounth = _OCTOBER;
else if($Newmounth == "November")
$Newmounth = _NOVEMBER;
else if($Newmounth == "December")
$Newmounth = _DECEMBER;


$date = $Newday." ".$Newdate." ".$Newmounth." ".$NewYear;

return $date;
}
Regards
Georges
Georges

User avatar
Georges Calvo
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Fri Jul 11, 2008 7:47 am
Location: France

Re: No translation on date format

Post by Georges Calvo » Fri Jul 11, 2008 12:09 pm

Ok, I found the solution, that functions with all the languages... thanks to you I could work on your source code. Thank you still. How you see by using $date simply is enough!

Code: Select all

function mosFormatDate( $date, $format="", $offset=NULL ){
	global $mosConfig_offset;
	if ( $format == '' ) {
		// %Y-%m-%d %H:%M:%S
		$format = _DATE_FORMAT_LC;
	}
	if ( is_null($offset) ) {
		$offset = $mosConfig_offset;
	}
	if ( $date && ereg( "([0-9]{4})-([0-9]{2})-([0-9]{2})[ ]([0-9]{2}):([0-9]{2}):([0-9]{2})", $date, $regs ) ) {
		$date = mktime( $regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1] );
		$date = $date > -1 ? strftime( $format, $date + ($offset*60*60) ) : '-';
	}
	
    //Translated
/**
* Days
*/
    if($date == 'Monday')
      $date = _MONDAY;
    else if($date == 'Tuesday')
      $date = _TUESDAY;
    else if($date == 'Wednesday')
      $date = _WEDNESDAY;
    else if($date == 'Thursday')
      $date = _THURSDAY;
    else if($date == 'Friday')
      $date = _FRIDAY;
    else if($date == 'Saturday')
      $date = _SATURDAY;
    else if($date == 'Sunday')
      $date = _SUNDAY;
/**
* Mounths
*/    
    if($date == 'January')
      $date = _JANUARY;
    else if($date == 'February')
      $date = _FEBRUARY;
    else if($date == 'March')
      $date = _MARCH;
    else if($date == 'April')
      $date = _APRIL;
    else if($date == 'May')
      $date = _MAY;
    else if($date == 'June')
      $date = _JUNE;
    else if($date == 'July')
      $date = _JULY;
    else if($date == 'August')
      $date = _AUGUST;
    else if($date == 'September')
      $date= _SEPTEMBER;
    else if($date == 'October')
      $date = _OCTOBER;
    else if($date == 'November')
      $date = _NOVEMBER;
    else if($date == 'December')
      $date = _DECEMBER;

	return $date;
}
Ciao, gladly
Georges

Istvan182
Joomla! Apprentice
Joomla! Apprentice
Posts: 12
Joined: Fri Jun 27, 2008 2:17 pm

Re: No translation on date format

Post by Istvan182 » Thu Jul 17, 2008 7:25 pm

I'm looking for this too, but the last solution by Georges Calvo doesn't work for me and the previous one show me the "classic date" near the "new" one: Thursday 17 July 2008 Thursday 17 test 2008 .

Any idea?
Thanks

User avatar
Georges Calvo
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Fri Jul 11, 2008 7:47 am
Location: France

Re: No translation on date format

Post by Georges Calvo » Thu Jul 17, 2008 10:13 pm

Istvan182 wrote:I'm looking for this too, but the last solution by Georges Calvo doesn't work for me and the previous one show me the "classic date" near the "new" one: Thursday 17 July 2008 Thursday 17 test 2008 .

Any idea?
Thanks
Hello,
Do you have a multilingual web site, with a file where are the files of the various languages?
If it is the case, then you must create in each language this:
/** In english */
DEFINE('_MONDAY','Monday');
DEFINE('_TUESDAY','Tuesday');
DEFINE('_WEDNESDAY','Wednesday');
DEFINE('_THURSDAY','Thursday');
DEFINE('_FRIDAY','Friday');
DEFINE('_SATURDAY','Saturday');
DEFINE('_SUNDAY','Sunday');

DEFINE('_JANUARY','January');
DEFINE('_FEBRUARY','February');
DEFINE('_MARCH','March');
DEFINE('_APRIL','April');
DEFINE('_MAY','May');
DEFINE('_JUNE','June');
DEFINE('_JULY','July');
DEFINE('_AUGUST','August');
DEFINE('_SEPTEMBER','September');
DEFINE('_OCTOBER','October');
DEFINE('_NOVEMBER','November');
DEFINE('_DECEMBER','December');
/** In german */
DEFINE('_MONDAY','Montag den');
DEFINE('_TUESDAY','Dienstag den');
DEFINE('_WEDNESDAY','Mittwoch den');
DEFINE('_THURSDAY','Donnerstag den');
DEFINE('_FRIDAY','Freitag den');
DEFINE('_SATURDAY','Samstag den');
DEFINE('_SUNDAY','Sonntag den');

DEFINE('_JANUARY','Januar');
DEFINE('_FEBRUARY','Februar');
DEFINE('_MARCH','März');
DEFINE('_APRIL','April');
DEFINE('_MAY','Mai');
DEFINE('_JUNE','Juni');
DEFINE('_JULY','Juli');
DEFINE('_AUGUST','August');
DEFINE('_SEPTEMBER','September');
DEFINE('_OCTOBER','Oktober');
DEFINE('_NOVEMBER','November');
DEFINE('_DECEMBER','Dezember');
...and the same for all the languages.
After, you put this code in “joomla.php” includes file, towards line 3700
/**
* Returns formated date according to current local and adds time offset
* @param string date in datetime format
* @param string format optional format for strftime
* @param offset time offset if different than global one
* @returns formated date
*/
function mosFormatDate( $date, $format="", $offset=NULL ){
global $mosConfig_offset;
if ( $format == '' ) {
// %Y-%m-%d %H:%M:%S
$format = _DATE_FORMAT_LC;
}
if ( is_null($offset) ) {
$offset = $mosConfig_offset;
}
if ( $date && ereg( "([0-9]{4})-([0-9]{2})-([0-9]{2})[ ]([0-9]{2}):([0-9]{2}):([0-9]{2})", $date, $regs ) ) {
$date = mktime( $regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1] );
$date = $date > -1 ? strftime( $format, $date + ($offset*60*60) ) : '-';
}
//Days and Months translated from languages file
if( $date == 'Monday' )
$date = _MONDAY;
else if( $date == 'Tuesday' )
$date = _TUESDAY;
else if( $date == 'Wednesday' )
$date = _WEDNESDAY;
else if( $date == 'Thursday' )
$date = _THURSDAY;
else if( $date == 'Friday' )
$date = _FRIDAY;
else if( $date == 'Saturday' )
$date = _SATURDAY;
else if( $date == 'Sunday' )
$date = _SUNDAY;

if( $date == 'January' )
$date = _JANUARY;
else if( $date == 'February' )
$date = _FEBRUARY;
else if( $date == 'March' )
$date = _MARCH;
else if( $date == 'April' )
$date = _APRIL;
else if( $date == 'May' )
$date = _MAY;
else if( $date == 'June' )
$date = _JUNE;
else if( $date == 'July' )
$date = _JULY;
else if( $date == 'August' )
$date = _AUGUST;
else if( $date == 'September' )
$date= _SEPTEMBER;
else if( $date == 'October' )
$date = _OCTOBER;
else if( $date == 'November' )
$date = _NOVEMBER;
else if( $date == 'December' )
$date = _DECEMBER;

return $date;
}
I hope that it's rather clear
Georges

madelman2
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 122
Joined: Tue Jun 19, 2007 3:52 am

Re: No translation on date format

Post by madelman2 » Fri Sep 12, 2008 6:09 pm

Georges Calvo solution is ok. But there is a problem there $date cannot be verified against only the day string or month string since $date is already formated to something including time. So what I did was to add another function in joomla.php:

function sent_date_to_translate ($date) {

//Days and Months translated from languages file

if(strstr($date,'Monday') !== false )
$date = str_replace("Monday",_MONDAY,$date);
else if( strstr($date,'Tuesday') !== false )
$date = str_replace("Tuesday",_TUESDAY,$date);
else if( strstr($date,'Wednesday') !== false )
$date = str_replace("Wednesday",_WEDNESDAY,$date);
else if( strstr($date,'Thursday') !== false )
$date = str_replace("Thursday",_THURSDAY,$date);
else if( strstr($date,'Friday') !== false )
$date = str_replace("Friday",_FRIDAY,$date);
else if( strstr($date,'Saturday') !== false )
$date = str_replace("Saturday",_SATURDAY,$date);
else if( strstr($date,'Sunday') !== false )
$date = str_replace("Sunday",_SUNDAY,$date);

if( strstr($date,'January') !== false )
$date = str_replace("January",_JANUARY,$date);
else if( strstr($date,'February') !== false )
$date = str_replace("February",_FEBRUARY,$date);
else if( strstr($date,'March') !== false )
$date = str_replace("March",_MARCH,$date);
else if( strstr($date,'April') !== false )
$date = str_replace("April",_APRIL,$date);
else if( strstr($date,'May') !== false )
$date = str_replace("May",_MAY,$date);
else if( strstr($date,'June') !== false )
$date = str_replace("June",_JUNE,$date);
else if( strstr($date,'July') !== false )
$date = str_replace("July",_JULY,$date);
else if( strstr($date,'August') !== false )
$date = str_replace("August",_AUGUST,$date);
else if( strstr($date,'September') !== false )
$date = str_replace("September",_SEPTEMBER,$date);
else if( strstr($date,'October') !== false )
$date = str_replace("October",_OCTOBER,$date);
else if( strstr($date,'November') !== false )
$date = str_replace("November",_NOVEMBER,$date);
else if( strstr($date,'December') !== false )
$date = str_replace("December",_DECEMBER,$date);


return $date;
}

That date can be just below after function mosCurrentDate.

Some modules (3rd parties) use mosCurrentDate and if you included the lines above in mosFormatDate function, your date is not going to be formatted. So instead doing twice, you can just call the function above and type in mosFormatDate and mosCurrentDate:

$date=sent_date_to_translate ($date) ;
return $date;

(before the return $date command)

.... and that will do it.

User avatar
biberce
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Sun Sep 28, 2008 4:55 pm

Re: No translation on date format

Post by biberce » Thu Oct 02, 2008 2:19 pm

Briliant. Thanks.

User avatar
infograf768
Joomla! Master
Joomla! Master
Posts: 19056
Joined: Fri Aug 12, 2005 3:47 pm
Location: **Translation Matters**

Re: No translation on date format

Post by infograf768 » Thu Oct 02, 2008 2:49 pm

FYI, this problem has been totally solved in 1.5 where the locale is not necessary anymore and all correct strings are picked up from a language ini file for the specific language.
Jean-Marie Simonet / infograf · http://www.info-graf.fr
---------------------------------
ex-Joomla Translation Coordination Team • ex-Joomla! Production Working Group

User avatar
Georges Calvo
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Fri Jul 11, 2008 7:47 am
Location: France

Re: No translation on date format

Post by Georges Calvo » Thu Oct 02, 2008 3:03 pm

Hello Jean-Marie,

Indeed, on 1.5 there's no more this problem, I had the occasion to test Joomla 1.5.7 into multilingual and all seems well to function.
Georges

Andriaz
Joomla! Apprentice
Joomla! Apprentice
Posts: 31
Joined: Sat Oct 18, 2008 9:54 pm

Re: No translation on date format

Post by Andriaz » Tue Oct 28, 2008 1:37 pm

Hi

I have the same problem with my website. I'm am also using Joomla 1.x and have the language date problem. I've tried Georges Calvo's solution. I've added the define dates in the language file but when I add the data in the Joomla.php file in the includes folder, my website crashes. I uploaded the original joomla.php file, so my website is running again.

What am I doing wrong?

Andriaz

Andriaz
Joomla! Apprentice
Joomla! Apprentice
Posts: 31
Joined: Sat Oct 18, 2008 9:54 pm

Re: No translation on date format

Post by Andriaz » Tue Oct 28, 2008 10:00 pm

Hi again

Nevermind. I found the problem.. I just didn't read careful enough :p I used ame268 idea, and it worked fine. I had some character problem with some letters, but I saved it to UTF-16 - problem solved :)

Thanks for this forum guys :)

User avatar
Georges Calvo
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Fri Jul 11, 2008 7:47 am
Location: France

Re: No translation on date format

Post by Georges Calvo » Wed Oct 29, 2008 12:03 am

Hi,
The solution that I employed is working for those which use several modules in the templates, and that working in this case.
Ciao, Georges
Georges

Andriaz
Joomla! Apprentice
Joomla! Apprentice
Posts: 31
Joined: Sat Oct 18, 2008 9:54 pm

Re: No translation on date format

Post by Andriaz » Wed Oct 29, 2008 12:16 am

Hi
Yes I understand. I didn't read careful enough :p sorry mate.


Locked

Return to “Language - 1.0.x”