I found that the locale is resetted BEFORE the month name is generated. So do the following:
FIND (~line 68)
// reset locale
setlocale(LC_TIME, $oldlocale);
CUT and INSERT AFTER:
$title = htmlentities(ucfirst($month_name)).' '.$year; #note that some locales don't capitalize month and day names
(After cutting, about 4 lines later.)
Complete new code I am working with:
global $wb, $database;
$days = array();
$day_name_length = 2;
$month_href = NULL;
$where = NULL;
$first_day = 1;
$pn = array();
$events = 0;
$oldlocale = setlocale(LC_TIME, NULL); #save current locale
setlocale(LC_TIME, 'de_DE');
if(!isset($year)) {$year = date('Y', time()); };
if(!isset($month)) {$month = date('n', time()); };
if ( isset( $section ) ) { $where = "AND section_id='$section'"; }
$today = date('j',time());
// Get Events from "Event Calendar" Module (1.8c)
$sql = "SELECT DAY(date) AS day, event_desc AS descr, evweb_url AS url FROM ".TABLE_PREFIX."mod_event_dates WHERE YEAR(date) = '$year' AND MONTH(date) = '$month' $where";
$result = $database->query($sql);
if ( $result->numRows() > 0 ) {
while( $row = $result->fetchRow() ) {
$text = $row['day'];
if ( ! empty( $row['descr'] ) ) {
$text .= ' <span>'.$row['descr'].'</span>';
}
if ( ! empty( $row['url'] ) ) {
$days[ $row['day'] ]
= array(
NULL,
NULL,
"<span style='font-weight: bold; border: 1px solid #f00;'>"
. "<a class='tooltip' href='".$row['url']."' target='_blank'>"
. $text
. "</a></span>"
);
}
else {
$days[ $row['day'] ]
= array(
NULL,
NULL,
"<span style='font-weight: bold; border: 1px solid #f00;'>"
. "<a class='tooltip' href='#'>"
. $text
. "</a></span>"
);
}
$events++;
}
}
if ( ! isset( $days[$today] ) ) {
$days[$today] = array( NULL, 'calendar-today' );
}
$first_of_month = gmmktime(0,0,0,$month,1,$year);
#remember that mktime will automatically correct if invalid dates are entered
# for instance, mktime(0,0,0,12,32,1997) will be the date for Jan 1, 1998
# this provides a built in "rounding" feature to generate_calendar()
$day_names = array(); #generate all the day names according to the current locale
for($n=0,$t=(3+$first_day)*86400; $n<7; $n++,$t+=86400) #January 4, 1970 was a Sunday
$day_names[$n] = ucfirst(gmstrftime('%A',$t)); #%A means full textual day name
list($month, $year, $month_name, $weekday) = explode(',',gmstrftime('%m,%Y,%B,%w',$first_of_month));
$weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day
$title = htmlentities(ucfirst($month_name)).' '.$year; #note that some locales don't capitalize month and day names
// reset locale
setlocale(LC_TIME, $oldlocale);
#Begin calendar. Uses a real <caption>. See http://diveintomark.org/archives/2002/07/03
@list($p, $pl) = each($pn); @list($n, $nl) = each($pn); #previous and next links, if applicable
if($p) $p = '<span class="calendar-prev">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span> ';
if($n) $n = ' <span class="calendar-next">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>';
$calendar = '<table class="calendar">'."\n".
'<caption class="calendar-month">'.$p.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title).$n."</caption>\n<tr>";
if($day_name_length){ #if the day names should be shown ($day_name_length > 0)
#if day_name_length is >3, the full name of the day will be printed
foreach($day_names as $d)
$calendar .= '<th abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</th>';
$calendar .= "</tr>\n<tr>";
}
if($weekday > 0) $calendar .= '<td colspan="'.$weekday.'"> </td>'; #initial 'empty' days
for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){
if($weekday == 7){
$weekday = 0; #start a new week
$calendar .= "</tr>\n<tr>";
}
if(isset($days[$day]) and is_array($days[$day])){
@list($link, $classes, $content) = $days[$day];
if(is_null($content)) $content = $day;
$calendar .= '<td'.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>').
($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).'</td>';
}
else $calendar .= "<td>$day</td>";
}
if($weekday != 7) $calendar .= '<td colspan="'.(7-$weekday).'"> </td>'; #remaining "empty" days
$calendar .= "</tr>\n</table><br />\n";
if ( $events == 0 ) {
$calendar .= 'Keine Termine für diesen Monat.<br />';
}
else {
$calendar .= $events.' '.'Termin'
. ( $events > 1 ? 'e' : '' )
. ' für diesen Monat.<br />';
}
return $calendar;