2 # .po as a wiki page type
3 # Licensed under GPL v2 or greater
4 # Copyright (C) 2008 intrigeri <intrigeri@boum.org>
5 # inspired by the GPL'd po4a-translate,
6 # which is Copyright 2002, 2003, 2004 by Martin Quinson (mquinson#debian.org)
7 package IkiWiki::Plugin::po;
13 use Locale::Po4a::Chooser;
26 memoize("istranslatable");
27 memoize("_istranslation");
28 memoize("percenttranslated");
31 hook(type => "getsetup", id => "po", call => \&getsetup);
32 hook(type => "checkconfig", id => "po", call => \&checkconfig);
33 hook(type => "needsbuild", id => "po", call => \&needsbuild);
34 hook(type => "scan", id => "po", call => \&scan, last =>1);
35 hook(type => "filter", id => "po", call => \&filter);
36 hook(type => "htmlize", id => "po", call => \&htmlize);
37 hook(type => "pagetemplate", id => "po", call => \&pagetemplate, last => 1);
38 hook(type => "postscan", id => "po", call => \&postscan);
39 hook(type => "rename", id => "po", call => \&renamepages);
40 hook(type => "delete", id => "po", call => \&mydelete);
41 hook(type => "change", id => "po", call => \&change);
42 hook(type => "canremove", id => "po", call => \&canremove);
43 hook(type => "editcontent", id => "po", call => \&editcontent);
45 $origsubs{'bestlink'}=\&IkiWiki::bestlink;
46 inject(name => "IkiWiki::bestlink", call => \&mybestlink);
47 $origsubs{'beautify_urlpath'}=\&IkiWiki::beautify_urlpath;
48 inject(name => "IkiWiki::beautify_urlpath", call => \&mybeautify_urlpath);
49 $origsubs{'targetpage'}=\&IkiWiki::targetpage;
50 inject(name => "IkiWiki::targetpage", call => \&mytargetpage);
51 $origsubs{'urlto'}=\&IkiWiki::urlto;
52 inject(name => "IkiWiki::urlto", call => \&myurlto);
53 $origsubs{'nicepagetitle'}=\&IkiWiki::nicepagetitle;
54 inject(name => "IkiWiki::nicepagetitle", call => \&mynicepagetitle);
63 # 2. Injected functions
64 # 3. Blackboxes for private data
79 po_master_language => {
85 description => "master language (non-PO files)",
89 po_slave_languages => {
96 description => "slave languages (PO files)",
100 po_translatable_pages => {
102 example => "!*/Discussion",
103 description => "PageSpec controlling which pages are translatable",
104 link => "ikiwiki/PageSpec",
110 example => "current",
111 description => "internal linking behavior (default/current/negotiated)",
115 po_translation_status_in_links => {
118 description => "display translation status in links to translations",
125 foreach my $field (qw{po_master_language po_slave_languages}) {
126 if (! exists $config{$field} || ! defined $config{$field}) {
127 error(sprintf(gettext("Must specify %s"), $field));
130 if (! (keys %{$config{po_slave_languages}})) {
131 error(gettext("At least one slave language must be defined in po_slave_languages"));
135 or error(sprintf(gettext("%s is not a valid language code"), $_));
136 } ($config{po_master_language}{code}, keys %{$config{po_slave_languages}});
137 if (! exists $config{po_translatable_pages} ||
138 ! defined $config{po_translatable_pages}) {
139 $config{po_translatable_pages}="";
141 if (! exists $config{po_link_to} ||
142 ! defined $config{po_link_to}) {
143 $config{po_link_to}='default';
146 $config{po_link_to} eq $_
147 } ('default', 'current', 'negotiated')) {
148 warn(sprintf(gettext('po_link_to=%s is not a valid setting, falling back to po_link_to=default'),
149 $config{po_link_to}));
150 $config{po_link_to}='default';
152 elsif ($config{po_link_to} eq "negotiated" && ! $config{usedirs}) {
153 warn(gettext('po_link_to=negotiated requires usedirs to be enabled, falling back to po_link_to=default'));
154 $config{po_link_to}='default';
156 if (! exists $config{po_translation_status_in_links} ||
157 ! defined $config{po_translation_status_in_links}) {
158 $config{po_translation_status_in_links}=1;
160 push @{$config{wiki_file_prune_regexps}}, qr/\.pot$/;
164 my $needsbuild=shift;
166 # backup @needsbuild content so that change() can know whether
167 # a given master page was rendered because its source file was changed
168 @origneedsbuild=(@$needsbuild);
171 buildtranslationscache();
173 # make existing translations depend on the corresponding master page
174 foreach my $master (keys %translations) {
175 map add_depends($_, $master), values %{otherlanguages($master)};
179 # Massage the recorded state of internal links so that:
180 # - it matches the actually generated links, rather than the links as written
181 # in the pages' source
182 # - backlinks are consistent in all cases
185 my $page=$params{page};
186 my $content=$params{content};
188 return unless UNIVERSAL::can("IkiWiki::Plugin::link", "import");
190 if (istranslation($page)) {
191 foreach my $destpage (@{$links{$page}}) {
192 if (istranslatable($destpage)) {
193 # replace one occurence of $destpage in $links{$page}
194 # (we only want to replace the one that was added by
195 # IkiWiki::Plugin::link::scan, other occurences may be
196 # there for other reasons)
197 for (my $i=0; $i<@{$links{$page}}; $i++) {
198 if (@{$links{$page}}[$i] eq $destpage) {
199 @{$links{$page}}[$i] = $destpage . '.' . lang($page);
206 elsif (! istranslatable($page) && ! istranslation($page)) {
207 foreach my $destpage (@{$links{$page}}) {
208 if (istranslatable($destpage)) {
209 # make sure any destpage's translations has
210 # $page in its backlinks
211 push @{$links{$page}},
212 values %{otherlanguages($destpage)};
218 # We use filter to convert PO to the master page's format,
219 # since the rest of ikiwiki should not work on PO files.
223 my $page = $params{page};
224 my $destpage = $params{destpage};
225 my $content = decode_utf8(encode_utf8($params{content}));
227 return $content if ( ! istranslation($page)
228 || alreadyfiltered($page, $destpage) );
230 # CRLF line terminators make poor Locale::Po4a feel bad
231 $content=~s/\r\n/\n/g;
233 # There are incompatibilities between some File::Temp versions
234 # (including 0.18, bundled with Lenny's perl-modules package)
235 # and others (e.g. 0.20, previously present in the archive as
236 # a standalone package): under certain circumstances, some
237 # return a relative filename, whereas others return an absolute one;
238 # we here use this module in a way that is at least compatible
239 # with 0.18 and 0.20. Beware, hit'n'run refactorers!
240 my $infile = new File::Temp(TEMPLATE => "ikiwiki-po-filter-in.XXXXXXXXXX",
241 DIR => File::Spec->tmpdir,
242 UNLINK => 1)->filename;
243 my $outfile = new File::Temp(TEMPLATE => "ikiwiki-po-filter-out.XXXXXXXXXX",
244 DIR => File::Spec->tmpdir,
245 UNLINK => 1)->filename;
247 writefile(basename($infile), File::Spec->tmpdir, $content);
249 my $masterfile = srcfile($pagesources{masterpage($page)});
251 "markdown" => (pagetype($masterfile) eq 'mdwn') ? 1 : 0,
253 my $doc=Locale::Po4a::Chooser::new('text',%options);
255 'po_in_name' => [ $infile ],
256 'file_in_name' => [ $masterfile ],
257 'file_in_charset' => 'utf-8',
258 'file_out_charset' => 'utf-8',
259 ) or error("[po/filter:$page]: failed to translate");
260 $doc->write($outfile) or error("[po/filter:$page] could not write $outfile");
261 $content = readfile($outfile) or error("[po/filter:$page] could not read $outfile");
263 # Unlinking should happen automatically, thanks to File::Temp,
264 # but it does not work here, probably because of the way writefile()
265 # and Locale::Po4a::write() work.
266 unlink $infile, $outfile;
268 setalreadyfiltered($page, $destpage);
275 my $page = $params{page};
276 my $content = $params{content};
278 # ignore PO files this plugin did not create
279 return $content unless istranslation($page);
281 # force content to be htmlize'd as if it was the same type as the master page
282 return IkiWiki::htmlize($page, $page,
283 pagetype(srcfile($pagesources{masterpage($page)})),
287 sub pagetemplate (@) {
289 my $page=$params{page};
290 my $destpage=$params{destpage};
291 my $template=$params{template};
293 my ($masterpage, $lang) = istranslation($page);
295 if (istranslation($page) && $template->query(name => "percenttranslated")) {
296 $template->param(percenttranslated => percenttranslated($page));
298 if ($template->query(name => "istranslation")) {
299 $template->param(istranslation => scalar istranslation($page));
301 if ($template->query(name => "istranslatable")) {
302 $template->param(istranslatable => istranslatable($page));
304 if ($template->query(name => "HOMEPAGEURL")) {
305 $template->param(homepageurl => homepageurl($page));
307 if ($template->query(name => "otherlanguages")) {
308 $template->param(otherlanguages => [otherlanguagesloop($page)]);
309 map add_depends($page, $_), (values %{otherlanguages($page)});
311 # Rely on IkiWiki::Render's genpage() to decide wether
312 # a discussion link should appear on $page; this is not
313 # totally accurate, though: some broken links may be generated
314 # when cgiurl is disabled.
315 # This compromise avoids some code duplication, and will probably
316 # prevent future breakage when ikiwiki internals change.
317 # Known limitations are preferred to future random bugs.
318 if ($template->param('discussionlink') && istranslation($page)) {
319 $template->param('discussionlink' => htmllink(
322 $masterpage . '/' . gettext("Discussion"),
325 linktext => gettext("Discussion"),
328 # Remove broken parentlink to ./index.html on home page's translations.
329 # It works because this hook has the "last" parameter set, to ensure it
330 # runs after parentlinks' own pagetemplate hook.
331 if ($template->param('parentlinks')
332 && istranslation($page)
333 && $masterpage eq "index") {
334 $template->param('parentlinks' => []);
340 my $page = $params{page};
342 # backlinks involve back-dependencies, so that nicepagetitle effects,
343 # such as translation status displayed in links, are updated
345 map add_depends($page, $_), keys %{$IkiWiki::backlinks{$page}};
348 # Add the renamed page translations to the list of to-be-renamed pages.
351 my @torename=@{$torename};
353 foreach my $rename (@torename) {
354 next unless istranslatable($rename->{src});
355 my %otherpages=%{otherlanguages($rename->{src})};
356 while (my ($lang, $otherpage) = each %otherpages) {
359 srcfile => $pagesources{$otherpage},
360 dest => otherlanguage($rename->{dest}, $lang),
361 destfile => $rename->{dest}.".".$lang.".po",
371 map { deletetranslations($_) } grep istranslatablefile($_), @deleted;
377 my $updated_po_files=0;
379 # Refresh/create POT and PO files as needed.
380 foreach my $file (grep {istranslatablefile($_)} @rendered) {
381 my $page=pagename($file);
382 my $masterfile=srcfile($file);
383 my $updated_pot_file=0;
384 # Only refresh Pot file if it does not exist, or if
385 # $pagesources{$page} was changed: don't if only the HTML was
386 # refreshed, e.g. because of a dependency.
387 if ((grep { $_ eq $pagesources{$page} } @origneedsbuild)
388 || ! -e potfile($masterfile)) {
389 refreshpot($masterfile);
394 push @pofiles, $_ if ($updated_pot_file || ! -e $_);
395 } (pofiles($masterfile));
397 refreshpofiles($masterfile, @pofiles);
398 map { IkiWiki::rcs_add($_) } @pofiles if $config{rcs};
403 if ($updated_po_files) {
405 gettext("updated PO files"),
406 "IkiWiki::Plugin::po::change");
410 sub canremove ($$$) {
411 my ($page, $cgi, $session) = (shift, shift, shift);
413 if (istranslation($page)) {
414 return gettext("Can not remove a translation. Removing the master page,".
415 "though, removes its translations as well.");
420 # As we're previewing or saving a page, the content may have
421 # changed, so tell the next filter() invocation it must not be lazy.
425 unsetalreadyfiltered($params{page}, $params{page});
426 return $params{content};
431 # | Injected functions
434 # Implement po_link_to 'current' and 'negotiated' settings.
435 sub mybestlink ($$) {
439 my $res=$origsubs{'bestlink'}->(masterpage($page), $link);
441 && ($config{po_link_to} eq "current" || $config{po_link_to} eq "negotiated")
442 && istranslatable($res)
443 && istranslation($page)) {
444 return $res . "." . lang($page);
449 sub mybeautify_urlpath ($) {
452 my $res=$origsubs{'beautify_urlpath'}->($url);
453 if ($config{po_link_to} eq "negotiated") {
454 $res =~ s!/\Qindex.$config{po_master_language}{code}.$config{htmlext}\E$!/!;
455 $res =~ s!/\Qindex.$config{htmlext}\E$!/!;
457 $res =~ s!/\Qindex.$_.$config{htmlext}\E$!/!;
458 } (keys %{$config{po_slave_languages}});
463 sub mytargetpage ($$) {
467 if (istranslation($page) || istranslatable($page)) {
468 my ($masterpage, $lang) = (masterpage($page), lang($page));
469 if (! $config{usedirs} || $masterpage eq 'index') {
470 return $masterpage . "." . $lang . "." . $ext;
473 return $masterpage . "/index." . $lang . "." . $ext;
476 return $origsubs{'targetpage'}->($page, $ext);
484 # workaround hard-coded /index.$config{htmlext} in IkiWiki::urlto()
486 && $config{po_link_to} eq "current"
487 && istranslatable('index')) {
488 return IkiWiki::beautify_urlpath(IkiWiki::baseurl($from) . "index." . lang($from) . ".$config{htmlext}");
490 # avoid using our injected beautify_urlpath if run by cgi_editpage,
491 # so that one is redirected to the just-edited page rather than to the
492 # negociated translation; to prevent unnecessary fiddling with caller/inject,
493 # we only do so when our beautify_urlpath would actually do what we want to
494 # avoid, i.e. when po_link_to = negotiated
495 if ($config{po_link_to} eq "negotiated") {
496 my @caller = caller(1);
497 my $run_by_editpage = 0;
498 $run_by_editpage = 1 if (exists $caller[3] && defined $caller[3]
499 && $caller[3] eq "IkiWiki::cgi_editpage");
500 inject(name => "IkiWiki::beautify_urlpath", call => $origsubs{'beautify_urlpath'})
502 my $res = $origsubs{'urlto'}->($to,$from,$absolute);
503 inject(name => "IkiWiki::beautify_urlpath", call => \&mybeautify_urlpath)
508 return $origsubs{'urlto'}->($to,$from,$absolute)
512 sub mynicepagetitle ($;$) {
513 my ($page, $unescaped) = (shift, shift);
515 my $res = $origsubs{'nicepagetitle'}->($page, $unescaped);
516 return $res unless istranslation($page);
517 return $res unless $config{po_translation_status_in_links};
518 return $res.' ('.percenttranslated($page).' %)';
522 # | Blackboxes for private data
528 sub alreadyfiltered($$) {
532 return ( exists $filtered{$page}{$destpage}
533 && $filtered{$page}{$destpage} eq 1 );
536 sub setalreadyfiltered($$) {
540 $filtered{$page}{$destpage}=1;
543 sub unsetalreadyfiltered($$) {
547 if (exists $filtered{$page}{$destpage}) {
548 delete $filtered{$page}{$destpage};
552 sub resetalreadyfiltered() {
561 sub maybe_add_leading_slash ($;$) {
564 $add=1 unless defined $add;
565 return '/' . $str if $add;
569 sub istranslatablefile ($) {
572 return 0 unless defined $file;
573 return 0 if (defined pagetype($file) && pagetype($file) eq 'po');
574 return 0 if $file =~ /\.pot$/;
575 return 1 if pagespec_match(pagename($file), $config{po_translatable_pages});
579 sub istranslatable ($) {
583 return 1 if istranslatablefile($pagesources{$page});
587 sub _istranslation ($) {
590 my $hasleadingslash = ($page=~s#^/##);
591 my $file=$pagesources{$page};
592 return 0 unless (defined $file
593 && defined pagetype($file)
594 && pagetype($file) eq 'po');
595 return 0 if $file =~ /\.pot$/;
597 my ($masterpage, $lang) = ($page =~ /(.*)[.]([a-z]{2})$/);
598 return 0 unless (defined $masterpage && defined $lang
599 && length $masterpage && length $lang
600 && defined $pagesources{$masterpage}
601 && defined $config{po_slave_languages}{$lang});
603 return (maybe_add_leading_slash($masterpage, $hasleadingslash), $lang)
604 if istranslatable($masterpage);
607 sub istranslation ($) {
610 if (1 < (my ($masterpage, $lang) = _istranslation($page))) {
611 my $hasleadingslash = ($masterpage=~s#^/##);
612 $translations{$masterpage}{$lang}=$page unless exists $translations{$masterpage}{$lang};
613 return (maybe_add_leading_slash($masterpage, $hasleadingslash), $lang);
621 if ( 1 < (my ($masterpage, $lang) = _istranslation($page))) {
630 if (1 < (my ($masterpage, $lang) = _istranslation($page))) {
633 return $config{po_master_language}{code};
636 sub islanguagecode ($) {
639 return ($code =~ /^[a-z]{2}$/);
642 sub otherlanguage ($$) {
646 return masterpage($page) if $code eq $config{po_master_language}{code};
647 return masterpage($page) . '.' . $code;
650 sub otherlanguages ($) {
654 return \%ret unless (istranslation($page) || istranslatable($page));
655 my $curlang=lang($page);
657 ($config{po_master_language}{code}, keys %{$config{po_slave_languages}}) {
658 next if $lang eq $curlang;
659 $ret{$lang}=otherlanguage($page, $lang);
665 my $masterfile=shift;
667 (my $name, my $dir, my $suffix) = fileparse($masterfile, qr/\.[^.]*/);
668 $dir='' if $dir eq './';
669 return File::Spec->catpath('', $dir, $name . ".pot");
673 my $masterfile=shift;
676 (my $name, my $dir, my $suffix) = fileparse($masterfile, qr/\.[^.]*/);
677 $dir='' if $dir eq './';
678 return File::Spec->catpath('', $dir, $name . "." . $lang . ".po");
682 my $masterfile=shift;
684 return map pofile($masterfile, $_), (keys %{$config{po_slave_languages}});
688 my $masterfile=shift;
690 my $potfile=potfile($masterfile);
691 my %options = ("markdown" => (pagetype($masterfile) eq 'mdwn') ? 1 : 0);
692 my $doc=Locale::Po4a::Chooser::new('text',%options);
693 $doc->{TT}{utf_mode} = 1;
694 $doc->{TT}{file_in_charset} = 'utf-8';
695 $doc->{TT}{file_out_charset} = 'utf-8';
696 $doc->read($masterfile);
697 # let's cheat a bit to force porefs option to be passed to Locale::Po4a::Po;
698 # this is undocument use of internal Locale::Po4a::TransTractor's data,
699 # compulsory since this module prevents us from using the porefs option.
700 $doc->{TT}{po_out}=Locale::Po4a::Po->new({ 'porefs' => 'none' });
701 $doc->{TT}{po_out}->set_charset('utf-8');
704 IkiWiki::prep_writefile(basename($potfile),dirname($potfile));
705 $doc->writepo($potfile);
708 sub refreshpofiles ($@) {
709 my $masterfile=shift;
712 my $potfile=potfile($masterfile);
713 error("[po/refreshpofiles] POT file ($potfile) does not exist") unless (-e $potfile);
715 foreach my $pofile (@pofiles) {
716 IkiWiki::prep_writefile(basename($pofile),dirname($pofile));
718 system("msgmerge", "-U", "--backup=none", $pofile, $potfile) == 0
719 or error("[po/refreshpofiles:$pofile] failed to update");
722 File::Copy::syscopy($potfile,$pofile)
723 or error("[po/refreshpofiles:$pofile] failed to copy the POT file");
728 sub buildtranslationscache() {
729 # use istranslation's side-effect
730 map istranslation($_), (keys %pagesources);
733 sub resettranslationscache() {
737 sub flushmemoizecache() {
738 Memoize::flush_cache("istranslatable");
739 Memoize::flush_cache("_istranslation");
740 Memoize::flush_cache("percenttranslated");
743 sub urlto_with_orig_beautiful_urlpath($$) {
747 inject(name => "IkiWiki::beautify_urlpath", call => $origsubs{'beautify_urlpath'});
748 my $res=urlto($to, $from);
749 inject(name => "IkiWiki::beautify_urlpath", call => \&mybeautify_urlpath);
754 sub percenttranslated ($) {
758 return gettext("N/A") unless istranslation($page);
759 my $file=srcfile($pagesources{$page});
760 my $masterfile = srcfile($pagesources{masterpage($page)});
762 "markdown" => (pagetype($masterfile) eq 'mdwn') ? 1 : 0,
764 my $doc=Locale::Po4a::Chooser::new('text',%options);
766 'po_in_name' => [ $file ],
767 'file_in_name' => [ $masterfile ],
768 'file_in_charset' => 'utf-8',
769 'file_out_charset' => 'utf-8',
770 ) or error("[po/percenttranslated:$page]: failed to translate");
771 my ($percent,$hit,$queries) = $doc->stats();
775 sub languagename ($) {
778 return $config{po_master_language}{name}
779 if $code eq $config{po_master_language}{code};
780 return $config{po_slave_languages}{$code}
781 if defined $config{po_slave_languages}{$code};
785 sub otherlanguagesloop ($) {
789 my %otherpages=%{otherlanguages($page)};
790 while (my ($lang, $otherpage) = each %otherpages) {
791 if (istranslation($page) && masterpage($page) eq $otherpage) {
793 url => urlto_with_orig_beautiful_urlpath($otherpage, $page),
795 language => languagename($lang),
801 url => urlto_with_orig_beautiful_urlpath($otherpage, $page),
803 language => languagename($lang),
804 percent => percenttranslated($otherpage),
809 return -1 if $a->{code} eq $config{po_master_language}{code};
810 return 1 if $b->{code} eq $config{po_master_language}{code};
811 return $a->{language} cmp $b->{language};
815 sub homepageurl (;$) {
818 return urlto('', $page);
821 sub deletetranslations ($) {
822 my $deletedmasterfile=shift;
824 my $deletedmasterpage=pagename($deletedmasterfile);
827 my $file = newpagefile($deletedmasterpage.'.'.$_, 'po');
828 my $absfile = "$config{srcdir}/$file";
829 if (-e $absfile && ! -l $absfile && ! -d $absfile) {
830 push @todelete, $file;
832 } keys %{$config{po_slave_languages}};
836 IkiWiki::rcs_remove($_);
839 IkiWiki::prune("$config{srcdir}/$_");
843 if (scalar @todelete) {
845 gettext("removed obsolete PO files"),
846 "IkiWiki::Plugin::po::deletetranslations");
850 sub commit_and_refresh ($$) {
851 my ($msg, $author) = (shift, shift);
854 IkiWiki::disable_commit_hook();
855 IkiWiki::rcs_commit_staged($msg, $author, "127.0.0.1");
856 IkiWiki::enable_commit_hook();
857 IkiWiki::rcs_update();
859 # Reinitialize module's private variables.
860 resetalreadyfiltered();
861 resettranslationscache();
863 # Trigger a wiki refresh.
864 require IkiWiki::Render;
865 # without preliminary saveindex/loadindex, refresh()
866 # complains about a lot of uninitialized variables
867 IkiWiki::saveindex();
868 IkiWiki::loadindex();
870 IkiWiki::saveindex();
877 package IkiWiki::PageSpec;
882 sub match_istranslation ($;@) {
885 if (IkiWiki::Plugin::po::istranslation($page)) {
886 return IkiWiki::SuccessReason->new("is a translation page");
889 return IkiWiki::FailReason->new("is not a translation page");
893 sub match_istranslatable ($;@) {
896 if (IkiWiki::Plugin::po::istranslatable($page)) {
897 return IkiWiki::SuccessReason->new("is set as translatable in po_translatable_pages");
900 return IkiWiki::FailReason->new("is not set as translatable in po_translatable_pages");
904 sub match_lang ($$;@) {
908 my $regexp=IkiWiki::glob2re($wanted);
909 my $lang=IkiWiki::Plugin::po::lang($page);
910 if ($lang!~/^$regexp$/i) {
911 return IkiWiki::FailReason->new("file language is $lang, not $wanted");
914 return IkiWiki::SuccessReason->new("file language is $wanted");
918 sub match_currentlang ($$;@) {
923 return IkiWiki::FailReason->new("no location provided") unless exists $params{location};
925 my $currentlang=IkiWiki::Plugin::po::lang($params{location});
926 my $lang=IkiWiki::Plugin::po::lang($page);
928 if ($lang eq $currentlang) {
929 return IkiWiki::SuccessReason->new("file language is the same as current one, i.e. $currentlang");
932 return IkiWiki::FailReason->new("file language is $lang, whereas current language is $currentlang");