Hello
Hm - at first: i apologize for my english.
The situation: every formated datestring produce via "date()" comes out
in english - regardless the setting of "setLocale", even if you want german
monthnames, or france, netherland ones.
Ok - strftime comes up within fine language specific formats, using "setLocale"
to specify the language. But the language_keys are differnd on differ server: e.g.
german could specify via "de_DE", "de@euro", "ger", "g" and so on.
Could be the hell on earth, even if the languagesettings are working local but differ
on the client-server.
The modul is build to make it easier to handel the situation if you want your own
date-format, e.g. "11. März 2009" instead of "03.11.09" or "2009-03-11", even in (nearly) all
supported languages of WB, and maybe also "dialects" like "de_AT" and/or "de_CH" ...
This (first public) alpha/beta Version 0.3.0 comes up as an easy to install/deinstall modul;
simple install it as a modul. After that you can use some (public) functions thru an
instance even in the frontend, e.g. inside a template, or the backend, inside a modul or other
core-files.
The documentation is in (my bad) english at all but comes up within a quick-start at this time, other
languages will follow, by clicking "about modules" and using the link following after "Doc" in the last line.
Some examples:
<?php
// setting the format
$d->format="%A, %d. %B %Y";
// This will return the date-string in the given format.
// e.g. below: 11. März 1966
$d->transform ("11/03/1966");
// This will return the current time in the format.
$d->toHTML();
// This also
$d->toHTML ( TIME() );
// This will set a new Language, e.g. italy.
$d->setLanguage ( array ("it_IT", "italiy", "it_IT@euro") );
// This will change all dates in a given string (pass by reference!).
$d->parse_string ("At 30.01.1998 the new book of Mr. Unknown comes ...");
// Testing a given language-key agains the locales and optional use them.
// Returns a list with all matches.
$all = $d->test_locale("de_AT", true);
foreach ($all as $tempKey) echo "< br />".$tempKey; // will result in:
de_AT
de_AT.ISO8859-1
de_AT.ISO8859-15
de_AT.UTF-8
?>
The following example comes from my modifications on "admin/pages/modify"
<?php
// Convert the unix ts for modified_when to human a readable form
if($results_array['modified_when'] != 0) {
/**
* Modify by Dietrich Roland Pehlke - aldus
*
* @ersion 0.1.0
* @date 2008-08-19
*
* Testing the use of x_cDate in the backend
*/
$temp_path = WB_PATH."/modules/x_cdate/include.php";
if (file_exists($temp_path)) {
require_once($temp_path);
$d = new c_date();
$d->set_wb_lang( LANGUAGE );
$d->format="<br />%A, %d. <font style='color:#900;'>%B</font> %Y -%H:%I:%S<br />";
$modified_ts = $d->toHTML( $results_array['modified_when']+TIMEZONE );
} else {
$modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE);
}
} else {
$modified_ts = 'Unknown';
}
?>
and for a frontend-example i've used a "Code2" Page:
<?php
$d = new c_date();
/**
* Changing the current format
*/
$d->format="%A, %d. <font style='color:#900;'><i>%B</i></font> %Y<br />";
echo $d->toHTML() ;
echo $d->transform("11/03/1966");
echo $d->transform("11.03.1966") ;
echo $d->transform("03-11-1966", 'm-d-y') ;
echo $d->transform("1966-03-11", 'y m D') ;
echo $d->transform("1966/03/11", 'ymd') ;
echo $d->transform("03/11/66", CDATE_USE_MDY) ;
echo $d->set_wb_lang("EN");
echo $d->toHTML() ;
$str = "<br><br>On 11.03.1998 Mr. Unkown has shown his new book »Anastasitica« inside his office.<br>";
$str .= "And on 03.06.2008 we will read it!<br />";
$d->parse_string($str);
echo $str;
$a = $d->test_locale("de_AT", false);
foreach ($a as $t) echo "<br />".$t;
echo "<br /><br />".$d->transform("11.01.66");
?>
If there are any problems while installing or any questions about the class, feel
free to drop a note or leave a comment here.
Regards
Aldus