On the date localization
Posted by Maksym
On the date localization March 17, 2004 09:03AM |
Registered: 23 years ago Posts: 13 |
From the thread phorum.org/phorum5/read.php?14,4656
The problem of the phorum date(s) localization.
First of all, I check the date format in "include/lang/my_language.php" file.
For example:
$PHORUM['long_date']=" j M. Y G:i";
$PHORUM['short_date']="d.m.Y G:i";
From the "[www.php.net]; we can see, that the format character "M" means "Jan", "Feb",... and so on.
But in my language the textual representations of the months sound as "Sich", "Lut", etc. (The same problem with "F" format character.)
So, in the "include/format_functions.php" file I have modified the function phorum_date() for my language and for my settings in lang-file.
function phorum_date( $picture, $ts )
{
$ukr_months = array("ñ³÷","ëþò", "áåð", "êâ³ò", "òðàâ", "÷åðâ", "ëèï", "ñåðï", "âåð", "æîâò", "ëèñò", "ãðóä");
/*My local names for "M" in format characters of my_language.php*/
$eng_months = array("Jan","Fab", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Now", "Dec");
/*English names*/
/*
Users can set english or default lang in the profile, not only my lang.
My lang is default, so I can use this instruction.
*/
if($GLOBALS['PHORUM']['user']['user_language'] == "english") {$eng_months = $ukr_months;}
$PHORUM = $GLOBALS["PHORUM"];
if(isset( $PHORUM["user"]["tz_offset"] ) ){
$ts += $PHORUM["user"]["tz_offset"] * 3600;
return str_replace( $eng_months, $ukr_months, gmdate( $picture, $ts ) );
} else {
$ts += $PHORUM["tz_offset"] * 3600;
return str_replace( $eng_months, $ukr_months, date( $picture, $ts ) );
}
}
The problem of the phorum date(s) localization.
First of all, I check the date format in "include/lang/my_language.php" file.
For example:
$PHORUM['long_date']=" j M. Y G:i";
$PHORUM['short_date']="d.m.Y G:i";
From the "[www.php.net]; we can see, that the format character "M" means "Jan", "Feb",... and so on.
But in my language the textual representations of the months sound as "Sich", "Lut", etc. (The same problem with "F" format character.)
So, in the "include/format_functions.php" file I have modified the function phorum_date() for my language and for my settings in lang-file.
function phorum_date( $picture, $ts )
{
$ukr_months = array("ñ³÷","ëþò", "áåð", "êâ³ò", "òðàâ", "÷åðâ", "ëèï", "ñåðï", "âåð", "æîâò", "ëèñò", "ãðóä");
/*My local names for "M" in format characters of my_language.php*/
$eng_months = array("Jan","Fab", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Now", "Dec");
/*English names*/
/*
Users can set english or default lang in the profile, not only my lang.
My lang is default, so I can use this instruction.
*/
if($GLOBALS['PHORUM']['user']['user_language'] == "english") {$eng_months = $ukr_months;}
$PHORUM = $GLOBALS["PHORUM"];
if(isset( $PHORUM["user"]["tz_offset"] ) ){
$ts += $PHORUM["user"]["tz_offset"] * 3600;
return str_replace( $eng_months, $ukr_months, gmdate( $picture, $ts ) );
} else {
$ts += $PHORUM["tz_offset"] * 3600;
return str_replace( $eng_months, $ukr_months, date( $picture, $ts ) );
}
}
Re: On the date localization March 18, 2004 04:00PM |
Registered: 20 years ago Posts: 683 |
Hi Maksym,
thank you for your effort, and thank you for showing me, that I am not the only one to have thought, that something should be done about it. Maybe Thomas, Brian & Co will consider to give it a shot, too. But I well understand that there are bigger Nuts to krack right now...
I might have a solution aswell: what about using something like:
In each Lang File:
$local = "de" // for German
or
$local = "en" // for English
and what have you...
and then use
setlocal ("LC_TIME","$local")
in cobination with the date() function of PHP.
thank you for your effort, and thank you for showing me, that I am not the only one to have thought, that something should be done about it. Maybe Thomas, Brian & Co will consider to give it a shot, too. But I well understand that there are bigger Nuts to krack right now...
I might have a solution aswell: what about using something like:
In each Lang File:
$local = "de" // for German
or
$local = "en" // for English
and what have you...
and then use
setlocal ("LC_TIME","$local")
in cobination with the date() function of PHP.
It is a great solution! Thank you.
Applying to the function phorum_date() your method, I get the following:
Modifications in lang file:
$local = "UK"; // Set your own location, of course
// See [www.w3.org]
$PHORUM['long_date']=" %d %b %Y, %H:%M";
$PHORUM['short_date']="%d.%m.%y %H:%M";
// See format string [www.php.net]
And the function itself:
function phorum_date( $picture, $ts )
{
setlocale(LC_TIME, $local);
$PHORUM = $GLOBALS["PHORUM"];
if(isset( $PHORUM["user"]["tz_offset"] ) ){
$ts += $PHORUM["user"]["tz_offset"] * 3600;
return gmstrftime( $picture, $ts );
} else {
$ts += $PHORUM["tz_offset"] * 3600;
return strftime( $picture, $ts );
}
}
Applying to the function phorum_date() your method, I get the following:
Modifications in lang file:
$local = "UK"; // Set your own location, of course
// See [www.w3.org]
$PHORUM['long_date']=" %d %b %Y, %H:%M";
$PHORUM['short_date']="%d.%m.%y %H:%M";
// See format string [www.php.net]
And the function itself:
function phorum_date( $picture, $ts )
{
setlocale(LC_TIME, $local);
$PHORUM = $GLOBALS["PHORUM"];
if(isset( $PHORUM["user"]["tz_offset"] ) ){
$ts += $PHORUM["user"]["tz_offset"] * 3600;
return gmstrftime( $picture, $ts );
} else {
$ts += $PHORUM["tz_offset"] * 3600;
return strftime( $picture, $ts );
}
}
Re: On the date localization March 21, 2004 03:08PM |
Admin Registered: 22 years ago Posts: 9,240 |
Sorry, only registered users may post in this forum.