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 => "editcontent", id => "po", call => \&editcontent);
44 $origsubs{'bestlink'}=\&IkiWiki::bestlink;
45 inject(name => "IkiWiki::bestlink", call => \&mybestlink);
46 $origsubs{'beautify_urlpath'}=\&IkiWiki::beautify_urlpath;
47 inject(name => "IkiWiki::beautify_urlpath", call => \&mybeautify_urlpath);
48 $origsubs{'targetpage'}=\&IkiWiki::targetpage;
49 inject(name => "IkiWiki::targetpage", call => \&mytargetpage);
50 $origsubs{'urlto'}=\&IkiWiki::urlto;
51 inject(name => "IkiWiki::urlto", call => \&myurlto);
52 $origsubs{'nicepagetitle'}=\&IkiWiki::nicepagetitle;
53 inject(name => "IkiWiki::nicepagetitle", call => \&mynicepagetitle);
62 # 2. Injected functions
63 # 3. Blackboxes for private data
78 po_master_language => {
84 description => "master language (non-PO files)",
88 po_slave_languages => {
95 description => "slave languages (PO files)",
99 po_translatable_pages => {
101 example => "!*/Discussion",
102 description => "PageSpec controlling which pages are translatable",
103 link => "ikiwiki/PageSpec",
109 example => "current",
110 description => "internal linking behavior (default/current/negotiated)",
114 po_translation_status_in_links => {
117 description => "display translation status in links to translations",
124 foreach my $field (qw{po_master_language po_slave_languages}) {
125 if (! exists $config{$field} || ! defined $config{$field}) {
126 error(sprintf(gettext("Must specify %s"), $field));
129 if (! (keys %{$config{po_slave_languages}})) {
130 error(gettext("At least one slave language must be defined in po_slave_languages"));
134 or error(sprintf(gettext("%s is not a valid language code"), $_));
135 } ($config{po_master_language}{code}, keys %{$config{po_slave_languages}});
136 if (! exists $config{po_translatable_pages} ||
137 ! defined $config{po_translatable_pages}) {
138 $config{po_translatable_pages}="";
140 if (! exists $config{po_link_to} ||
141 ! defined $config{po_link_to}) {
142 $config{po_link_to}='default';
145 $config{po_link_to} eq $_
146 } ('default', 'current', 'negotiated')) {
147 warn(sprintf(gettext('po_link_to=%s is not a valid setting, falling back to po_link_to=default'),
148 $config{po_link_to}));
149 $config{po_link_to}='default';
151 elsif ($config{po_link_to} eq "negotiated" && ! $config{usedirs}) {
152 warn(gettext('po_link_to=negotiated requires usedirs to be enabled, falling back to po_link_to=default'));
153 $config{po_link_to}='default';
155 if (! exists $config{po_translation_status_in_links} ||
156 ! defined $config{po_translation_status_in_links}) {
157 $config{po_translation_status_in_links}=1;
159 push @{$config{wiki_file_prune_regexps}}, qr/\.pot$/;
163 my $needsbuild=shift;
165 # backup @needsbuild content so that change() can know whether
166 # a given master page was rendered because its source file was changed
167 @origneedsbuild=(@$needsbuild);
170 buildtranslationscache();
172 # make existing translations depend on the corresponding master page
173 foreach my $master (keys %translations) {
174 map add_depends($_, $master), values %{otherlanguages($master)};
178 # Massage the recorded state of internal links so that:
179 # - it matches the actually generated links, rather than the links as written
180 # in the pages' source
181 # - backlinks are consistent in all cases
184 my $page=$params{page};
185 my $content=$params{content};
187 return unless UNIVERSAL::can("IkiWiki::Plugin::link", "import");
189 if (istranslation($page)) {
190 foreach my $destpage (@{$links{$page}}) {
191 if (istranslatable($destpage)) {
192 # replace one occurence of $destpage in $links{$page}
193 # (we only want to replace the one that was added by
194 # IkiWiki::Plugin::link::scan, other occurences may be
195 # there for other reasons)
196 for (my $i=0; $i<@{$links{$page}}; $i++) {
197 if (@{$links{$page}}[$i] eq $destpage) {
198 @{$links{$page}}[$i] = $destpage . '.' . lang($page);
205 elsif (! istranslatable($page) && ! istranslation($page)) {
206 foreach my $destpage (@{$links{$page}}) {
207 if (istranslatable($destpage)) {
208 # make sure any destpage's translations has
209 # $page in its backlinks
210 push @{$links{$page}},
211 values %{otherlanguages($destpage)};
217 # We use filter to convert PO to the master page's format,
218 # since the rest of ikiwiki should not work on PO files.
222 my $page = $params{page};
223 my $destpage = $params{destpage};
224 my $content = decode_utf8(encode_utf8($params{content}));
226 return $content if ( ! istranslation($page)
227 || alreadyfiltered($page, $destpage) );
229 # CRLF line terminators make poor Locale::Po4a feel bad
230 $content=~s/\r\n/\n/g;
232 # Implementation notes
234 # 1. Locale::Po4a reads/writes from/to files, and I'm too lazy
235 # to learn how to disguise a variable as a file.
236 # 2. There are incompatibilities between some File::Temp versions
237 # (including 0.18, bundled with Lenny's perl-modules package)
238 # and others (e.g. 0.20, previously present in the archive as
239 # a standalone package): under certain circumstances, some
240 # return a relative filename, whereas others return an absolute one;
241 # we here use this module in a way that is at least compatible
242 # with 0.18 and 0.20. Beware, hit'n'run refactorers!
243 my $infile = new File::Temp(TEMPLATE => "ikiwiki-po-filter-in.XXXXXXXXXX",
244 DIR => File::Spec->tmpdir,
245 UNLINK => 1)->filename;
246 my $outfile = new File::Temp(TEMPLATE => "ikiwiki-po-filter-out.XXXXXXXXXX",
247 DIR => File::Spec->tmpdir,
248 UNLINK => 1)->filename;
250 writefile(basename($infile), File::Spec->tmpdir, $content);
252 my $masterfile = srcfile($pagesources{masterpage($page)});
255 push @masters,$masterfile;
257 "markdown" => (pagetype($masterfile) eq 'mdwn') ? 1 : 0,
259 my $doc=Locale::Po4a::Chooser::new('text',%options);
261 'po_in_name' => \@pos,
262 'file_in_name' => \@masters,
263 'file_in_charset' => 'utf-8',
264 'file_out_charset' => 'utf-8',
265 ) or error("[po/filter:$page]: failed to translate");
266 $doc->write($outfile) or error("[po/filter:$page] could not write $outfile");
267 $content = readfile($outfile) or error("[po/filter:$page] could not read $outfile");
269 # Unlinking should happen automatically, thanks to File::Temp,
270 # but it does not work here, probably because of the way writefile()
271 # and Locale::Po4a::write() work.
272 unlink $infile, $outfile;
274 setalreadyfiltered($page, $destpage);
281 my $page = $params{page};
282 my $content = $params{content};
284 # ignore PO files this plugin did not create
285 return $content unless istranslation($page);
287 # force content to be htmlize'd as if it was the same type as the master page
288 return IkiWiki::htmlize($page, $page,
289 pagetype(srcfile($pagesources{masterpage($page)})),
293 sub pagetemplate (@) {
295 my $page=$params{page};
296 my $destpage=$params{destpage};
297 my $template=$params{template};
299 my ($masterpage, $lang) = istranslation($page);
301 if (istranslation($page) && $template->query(name => "percenttranslated")) {
302 $template->param(percenttranslated => percenttranslated($page));
304 if ($template->query(name => "istranslation")) {
305 $template->param(istranslation => scalar istranslation($page));
307 if ($template->query(name => "istranslatable")) {
308 $template->param(istranslatable => istranslatable($page));
310 if ($template->query(name => "HOMEPAGEURL")) {
311 $template->param(homepageurl => homepageurl($page));
313 if ($template->query(name => "otherlanguages")) {
314 $template->param(otherlanguages => [otherlanguagesloop($page)]);
315 map add_depends($page, $_), (values %{otherlanguages($page)});
317 # Rely on IkiWiki::Render's genpage() to decide wether
318 # a discussion link should appear on $page; this is not
319 # totally accurate, though: some broken links may be generated
320 # when cgiurl is disabled.
321 # This compromise avoids some code duplication, and will probably
322 # prevent future breakage when ikiwiki internals change.
323 # Known limitations are preferred to future random bugs.
324 if ($template->param('discussionlink') && istranslation($page)) {
325 $template->param('discussionlink' => htmllink(
328 $masterpage . '/' . gettext("Discussion"),
331 linktext => gettext("Discussion"),
334 # Remove broken parentlink to ./index.html on home page's translations.
335 # It works because this hook has the "last" parameter set, to ensure it
336 # runs after parentlinks' own pagetemplate hook.
337 if ($template->param('parentlinks')
338 && istranslation($page)
339 && $masterpage eq "index") {
340 $template->param('parentlinks' => []);
346 my $page = $params{page};
348 # backlinks involve back-dependencies, so that nicepagetitle effects,
349 # such as translation status displayed in links, are updated
351 map add_depends($page, $_), keys %{$IkiWiki::backlinks{$page}};
354 # Add the renamed page translations to the list of to-be-renamed pages.
355 # Save information about master page rename, so that:
356 # - our delete hook can ignore the translations not renamed already
357 # - our change hook can rename the translations accordingly.
360 my @torename=@{$torename};
362 foreach my $rename (@torename) {
363 next unless istranslatable($rename->{src});
364 my %otherpages=%{otherlanguages($rename->{src})};
365 while (my ($lang, $otherpage) = each %otherpages) {
368 srcfile => $pagesources{$otherpage},
369 dest => otherlanguage($rename->{dest}, $lang),
370 destfile => $rename->{dest}.".".$lang.".po",
381 deletetranslations($_);
382 } grep { istranslatablefile($_) } @deleted;
388 my $updated_po_files=0;
390 # Refresh/create POT and PO files as needed.
391 foreach my $file (@rendered) {
392 next unless istranslatablefile($file);
393 my $page=pagename($file);
394 my $masterfile=srcfile($file);
395 my $updated_pot_file=0;
396 # Only refresh Pot file if it does not exist, or if
397 # $pagesources{$page} was changed: don't if only the HTML was
398 # refreshed, e.g. because of a dependency.
399 if ((grep { $_ eq $pagesources{$page} } @origneedsbuild)
400 || ! -e potfile($masterfile)) {
401 refreshpot($masterfile);
406 push @pofiles, $_ if ($updated_pot_file || ! -e $_);
407 } (pofiles($masterfile));
409 refreshpofiles($masterfile, @pofiles);
410 map { IkiWiki::rcs_add($_); } @pofiles if ($config{rcs});
415 if ($updated_po_files) {
417 gettext("updated PO files"),
418 "IkiWiki::Plugin::po::change");
422 # As we're previewing or saving a page, the content may have
423 # changed, so tell the next filter() invocation it must not be lazy.
427 unsetalreadyfiltered($params{page}, $params{page});
428 return $params{content};
433 # | Injected functions
436 # Implement po_link_to 'current' and 'negotiated' settings.
437 sub mybestlink ($$) {
441 my $res=$origsubs{'bestlink'}->(masterpage($page), $link);
443 && ($config{po_link_to} eq "current" || $config{po_link_to} eq "negotiated")
444 && istranslatable($res)
445 && istranslation($page)) {
446 return $res . "." . lang($page);
451 sub mybeautify_urlpath ($) {
454 my $res=$origsubs{'beautify_urlpath'}->($url);
455 if ($config{po_link_to} eq "negotiated") {
456 $res =~ s!/\Qindex.$config{po_master_language}{code}.$config{htmlext}\E$!/!;
457 $res =~ s!/\Qindex.$config{htmlext}\E$!/!;
459 $res =~ s!/\Qindex.$_.$config{htmlext}\E$!/!;
460 } (keys %{$config{po_slave_languages}});
465 sub mytargetpage ($$) {
469 if (istranslation($page) || istranslatable($page)) {
470 my ($masterpage, $lang) = (masterpage($page), lang($page));
471 if (! $config{usedirs} || $masterpage eq 'index') {
472 return $masterpage . "." . $lang . "." . $ext;
475 return $masterpage . "/index." . $lang . "." . $ext;
478 return $origsubs{'targetpage'}->($page, $ext);
486 # workaround hard-coded /index.$config{htmlext} in IkiWiki::urlto()
488 && $config{po_link_to} eq "current"
489 && istranslatable('index')) {
490 return IkiWiki::beautify_urlpath(IkiWiki::baseurl($from) . "index." . lang($from) . ".$config{htmlext}");
492 # avoid using our injected beautify_urlpath if run by cgi_editpage,
493 # so that one is redirected to the just-edited page rather than to the
494 # negociated translation; to prevent unnecessary fiddling with caller/inject,
495 # we only do so when our beautify_urlpath would actually do what we want to
496 # avoid, i.e. when po_link_to = negotiated
497 if ($config{po_link_to} eq "negotiated") {
498 my @caller = caller(1);
499 my $run_by_editpage = ($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 my %po_options = ('porefs' => 'none');
701 $doc->{TT}{po_out}=Locale::Po4a::Po->new(\%po_options);
702 $doc->{TT}{po_out}->set_charset('utf-8');
705 IkiWiki::prep_writefile(basename($potfile),dirname($potfile));
706 $doc->writepo($potfile);
709 sub refreshpofiles ($@) {
710 my $masterfile=shift;
713 my $potfile=potfile($masterfile);
714 error("[po/refreshpofiles] POT file ($potfile) does not exist") unless (-e $potfile);
716 foreach my $pofile (@pofiles) {
717 IkiWiki::prep_writefile(basename($pofile),dirname($pofile));
719 system("msgmerge", "-U", "--backup=none", $pofile, $potfile) == 0
720 or error("[po/refreshpofiles:$pofile] failed to update");
723 File::Copy::syscopy($potfile,$pofile)
724 or error("[po/refreshpofiles:$pofile] failed to copy the POT file");
729 sub buildtranslationscache() {
730 # use istranslation's side-effect
731 map istranslation($_), (keys %pagesources);
734 sub resettranslationscache() {
738 sub flushmemoizecache() {
739 Memoize::flush_cache("istranslatable");
740 Memoize::flush_cache("_istranslation");
741 Memoize::flush_cache("percenttranslated");
744 sub urlto_with_orig_beautiful_urlpath($$) {
748 inject(name => "IkiWiki::beautify_urlpath", call => $origsubs{'beautify_urlpath'});
749 my $res=urlto($to, $from);
750 inject(name => "IkiWiki::beautify_urlpath", call => \&mybeautify_urlpath);
755 sub percenttranslated ($) {
759 return gettext("N/A") unless istranslation($page);
760 my $file=srcfile($pagesources{$page});
761 my $masterfile = srcfile($pagesources{masterpage($page)});
764 push @masters,$masterfile;
766 "markdown" => (pagetype($masterfile) eq 'mdwn') ? 1 : 0,
768 my $doc=Locale::Po4a::Chooser::new('text',%options);
770 'po_in_name' => \@pos,
771 'file_in_name' => \@masters,
772 'file_in_charset' => 'utf-8',
773 'file_out_charset' => 'utf-8',
774 ) or error("[po/percenttranslated:$page]: failed to translate");
775 my ($percent,$hit,$queries) = $doc->stats();
779 sub languagename ($) {
782 return $config{po_master_language}{name}
783 if $code eq $config{po_master_language}{code};
784 return $config{po_slave_languages}{$code}
785 if defined $config{po_slave_languages}{$code};
789 sub otherlanguagesloop ($) {
793 my %otherpages=%{otherlanguages($page)};
794 while (my ($lang, $otherpage) = each %otherpages) {
795 if (istranslation($page) && masterpage($page) eq $otherpage) {
797 url => urlto_with_orig_beautiful_urlpath($otherpage, $page),
799 language => languagename($lang),
805 url => urlto_with_orig_beautiful_urlpath($otherpage, $page),
807 language => languagename($lang),
808 percent => percenttranslated($otherpage),
813 return -1 if $a->{code} eq $config{po_master_language}{code};
814 return 1 if $b->{code} eq $config{po_master_language}{code};
815 return $a->{language} cmp $b->{language};
819 sub homepageurl (;$) {
822 return urlto('', $page);
825 sub deletetranslations ($) {
826 my $deletedmasterfile=shift;
828 my $deletedmasterpage=pagename($deletedmasterfile);
831 my $file = newpagefile($deletedmasterpage.'.'.$_, 'po');
832 my $absfile = "$config{srcdir}/$file";
833 if (-e $absfile && ! -l $absfile && ! -d $absfile) {
834 push @todelete, $file;
836 } keys %{$config{po_slave_languages}};
840 IkiWiki::rcs_remove($_);
843 IkiWiki::prune("$config{srcdir}/$_");
847 if (scalar @todelete) {
849 gettext("removed obsolete PO files"),
850 "IkiWiki::Plugin::po::deletetranslations");
854 sub commit_and_refresh ($$) {
855 my ($msg, $author) = (shift, shift);
858 IkiWiki::disable_commit_hook();
859 IkiWiki::rcs_commit_staged($msg, $author, "127.0.0.1");
860 IkiWiki::enable_commit_hook();
861 IkiWiki::rcs_update();
863 # Reinitialize module's private variables.
864 resetalreadyfiltered();
865 resettranslationscache();
867 # Trigger a wiki refresh.
868 require IkiWiki::Render;
869 # without preliminary saveindex/loadindex, refresh()
870 # complains about a lot of uninitialized variables
871 IkiWiki::saveindex();
872 IkiWiki::loadindex();
874 IkiWiki::saveindex();
881 package IkiWiki::PageSpec;
886 sub match_istranslation ($;@) {
889 if (IkiWiki::Plugin::po::istranslation($page)) {
890 return IkiWiki::SuccessReason->new("is a translation page");
893 return IkiWiki::FailReason->new("is not a translation page");
897 sub match_istranslatable ($;@) {
900 if (IkiWiki::Plugin::po::istranslatable($page)) {
901 return IkiWiki::SuccessReason->new("is set as translatable in po_translatable_pages");
904 return IkiWiki::FailReason->new("is not set as translatable in po_translatable_pages");
908 sub match_lang ($$;@) {
912 my $regexp=IkiWiki::glob2re($wanted);
913 my $lang=IkiWiki::Plugin::po::lang($page);
914 if ($lang!~/^$regexp$/i) {
915 return IkiWiki::FailReason->new("file language is $lang, not $wanted");
918 return IkiWiki::SuccessReason->new("file language is $wanted");
922 sub match_currentlang ($$;@) {
927 return IkiWiki::FailReason->new("no location provided") unless exists $params{location};
929 my $currentlang=IkiWiki::Plugin::po::lang($params{location});
930 my $lang=IkiWiki::Plugin::po::lang($page);
932 if ($lang eq $currentlang) {
933 return IkiWiki::SuccessReason->new("file language is the same as current one, i.e. $currentlang");
936 return IkiWiki::FailReason->new("file language is $lang, whereas current language is $currentlang");