3 I studied this [[guy's problem|forum/Encoding_problem_in_french_with_ikiwiki-calendar]] and I propose here a (dirty) hack to correct it.
5 The problem is that in French, for example, "December" is "Décembre" which, because of encoding problems, is rendered as "Décembre".
7 I managed to track this problem down to an encoding problem of `POSIX::strftime` in `Ikiwiki/Plugin/calendar.pm`. I used [[this guy's solution|http://www.perlmonks.org/?node_id=857018]] to solve the problem (the diff is printed below).
9 The problem is that I do not know Perl, encoding is one of the thing I would be happy not to dive into, and it is the first time I contribute to Ikiwiki: I copied and made a few changes to the code I found without understanding it. So I am not sure that my code is neat, or works in every situation. Feel free to improve it!
15 diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm
16 index c7d2b7c..1345939 100644
17 --- a/IkiWiki/Plugin/calendar.pm
18 +++ b/IkiWiki/Plugin/calendar.pm
19 @@ -22,7 +22,14 @@ use warnings;
25 +use POSIX qw/setlocale LC_TIME strftime/;
27 +my ($strftime_encoding)= setlocale(LC_TIME)=~m#\.([^@]+)#;
29 +# try to return an utf8 value from strftime
30 + $strftime_encoding ? Encode::decode($strftime_encoding, &strftime) : &strftime;
34 my @now=localtime($time);
35 @@ -123,10 +130,10 @@ sub format_month (@) {
38 # Find out month names for this, next, and previous months
39 - my $monthabbrev=POSIX::strftime("%b", @monthstart);
40 - my $monthname=POSIX::strftime("%B", @monthstart);
41 - my $pmonthname=POSIX::strftime("%B", localtime(timelocal(0,0,0,1,$pmonth-1,$pyear-1900)));
42 - my $nmonthname=POSIX::strftime("%B", localtime(timelocal(0,0,0,1,$nmonth-1,$nyear-1900)));
43 + my $monthabbrev=strftime_utf8("%b", @monthstart);
44 + my $monthname=strftime_utf8("%B", @monthstart);
45 + my $pmonthname=strftime_utf8("%B", localtime(timelocal(0,0,0,1,$pmonth-1,$pyear-1900)));
46 + my $nmonthname=strftime_utf8("%B", localtime(timelocal(0,0,0,1,$nmonth-1,$nyear-1900)));
48 my $archivebase = 'archives';
49 $archivebase = $config{archivebase} if defined $config{archivebase};
50 @@ -182,7 +189,7 @@ EOF
52 for my $dow ($week_start_day..$week_start_day+6) {
53 my @day=localtime(timelocal(0,0,0,$start_day++,$params{month}-1,$params{year}-1900));
54 - my $downame = POSIX::strftime("%A", @day);
55 + my $downame = strftime_utf8("%A", @day);
56 my $dowabbr = substr($downame, 0, 1);
57 $downame{$dow % 7}=$downame;
58 $dowabbr{$dow % 7}=$dowabbr;
59 @@ -329,8 +336,8 @@ EOF
60 for (my $month = 1; $month <= 12; $month++) {
61 my @day=localtime(timelocal(0,0,0,15,$month-1,$params{year}-1900));
63 - my $monthname = POSIX::strftime("%B", @day);
64 - my $monthabbr = POSIX::strftime("%b", @day);
65 + my $monthname = strftime_utf8("%B", @day);
66 + my $monthabbr = strftime_utf8("%b", @day);
67 $calendar.=qq{\t<tr>\n} if ($month % $params{months_per_row} == 1);
69 my $mtag=sprintf("%02d", $month);