Quote from: Steffen.Larsen at Nov 08, 2007, 06:30 AM
Yes.
In the ditto call, I use this: &dateFormat=`%d. %B %Y`
In the chunk, I use this tag: [+date+]
Can I change the locale in the dateFormat? I couldn’t find any mention of it in the references I found.
I think I found a solution: in the snippets folder look for /ditto/classes/ditto.class.inc.php
Then look for "function formatDate" (line 922):
function formatDate($dateUnixTime, $dateFormat) {
global $modx;
$dt = strftime($dateFormat, (intval($dateUnixTime) + $modx->config["server_offset_time"]));
if ($modx->config["modx_charset"] == "UTF-8") {
$dt = utf8_encode($dt);
}
return $dt;
}
now insert "setlocale(LC_TIME, "da_DK.UTF8");" after "global $modx", so it looks like that:
function formatDate($dateUnixTime, $dateFormat) {
global $modx;
setlocale(LC_ALL, "da_DK.UTF8");
$dt = strftime($dateFormat, (intval($dateUnixTime) + $modx->config["server_offset_time"]));
if ($modx->config["modx_charset"] == "UTF-8") {
$dt = utf8_encode($dt);
}
return $dt;
}
I wish we could setlocale somewhere as a global setting in MODx, or maybe on the level of snippets or plugins configuration, in case we have multilanguage sites. Because by hacking the ditto files directly, you have to keep track of those changes in case you’re updating ditto.