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 Bug summary: when using the [[calendar plugin|plugins/calendar]] in French (`LANG=fr_FR.UTF-8`), "Décembre" (French for "December") 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 (help me to) improve it!
14 > Yes, this seems basically right. I've applied a modified version of this.
19 diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm
20 index c7d2b7c..1345939 100644
21 --- a/IkiWiki/Plugin/calendar.pm
22 +++ b/IkiWiki/Plugin/calendar.pm
23 @@ -22,7 +22,14 @@ use warnings;
29 +use POSIX qw/setlocale LC_TIME strftime/;
31 +my ($strftime_encoding)= setlocale(LC_TIME)=~m#\.([^@]+)#;
33 +# try to return an utf8 value from strftime
34 + $strftime_encoding ? Encode::decode($strftime_encoding, &strftime) : &strftime;
38 my @now=localtime($time);
39 @@ -123,10 +130,10 @@ sub format_month (@) {
42 # Find out month names for this, next, and previous months
43 - my $monthabbrev=POSIX::strftime("%b", @monthstart);
44 - my $monthname=POSIX::strftime("%B", @monthstart);
45 - my $pmonthname=POSIX::strftime("%B", localtime(timelocal(0,0,0,1,$pmonth-1,$pyear-1900)));
46 - my $nmonthname=POSIX::strftime("%B", localtime(timelocal(0,0,0,1,$nmonth-1,$nyear-1900)));
47 + my $monthabbrev=strftime_utf8("%b", @monthstart);
48 + my $monthname=strftime_utf8("%B", @monthstart);
49 + my $pmonthname=strftime_utf8("%B", localtime(timelocal(0,0,0,1,$pmonth-1,$pyear-1900)));
50 + my $nmonthname=strftime_utf8("%B", localtime(timelocal(0,0,0,1,$nmonth-1,$nyear-1900)));
52 my $archivebase = 'archives';
53 $archivebase = $config{archivebase} if defined $config{archivebase};
54 @@ -182,7 +189,7 @@ EOF
56 for my $dow ($week_start_day..$week_start_day+6) {
57 my @day=localtime(timelocal(0,0,0,$start_day++,$params{month}-1,$params{year}-1900));
58 - my $downame = POSIX::strftime("%A", @day);
59 + my $downame = strftime_utf8("%A", @day);
60 my $dowabbr = substr($downame, 0, 1);
61 $downame{$dow % 7}=$downame;
62 $dowabbr{$dow % 7}=$dowabbr;
63 @@ -329,8 +336,8 @@ EOF
64 for (my $month = 1; $month <= 12; $month++) {
65 my @day=localtime(timelocal(0,0,0,15,$month-1,$params{year}-1900));
67 - my $monthname = POSIX::strftime("%B", @day);
68 - my $monthabbr = POSIX::strftime("%b", @day);
69 + my $monthname = strftime_utf8("%B", @day);
70 + my $monthabbr = strftime_utf8("%b", @day);
71 $calendar.=qq{\t<tr>\n} if ($month % $params{months_per_row} == 1);
73 my $mtag=sprintf("%02d", $month);