summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/po.pm
blob: c8ec37c228378d600ae526086b5fe97fb2ac503d (plain)
  1. #!/usr/bin/perl
  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;
  8. use warnings;
  9. use strict;
  10. use IkiWiki 2.00;
  11. use Encode;
  12. use Locale::Po4a::Chooser;
  13. use Locale::Po4a::Po;
  14. use File::Basename;
  15. use File::Copy;
  16. use File::Spec;
  17. use File::Temp;
  18. use Memoize;
  19. my %translations;
  20. my @origneedsbuild;
  21. our %filtered;
  22. memoize("_istranslation");
  23. memoize("percenttranslated");
  24. # FIXME: memoizing istranslatable() makes some test cases fail once every
  25. # two tries; this may be related to the artificial way the testsuite is
  26. # run, or not.
  27. # memoize("istranslatable");
  28. # backup references to subs that will be overriden
  29. my %origsubs;
  30. sub import { #{{{
  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 => "filter", id => "po", call => \&filter);
  35. hook(type => "htmlize", id => "po", call => \&htmlize);
  36. hook(type => "pagetemplate", id => "po", call => \&pagetemplate, last => 1);
  37. hook(type => "change", id => "po", call => \&change);
  38. hook(type => "editcontent", id => "po", call => \&editcontent);
  39. $origsubs{'bestlink'}=\&IkiWiki::bestlink;
  40. inject(name => "IkiWiki::bestlink", call => \&mybestlink);
  41. $origsubs{'beautify_urlpath'}=\&IkiWiki::beautify_urlpath;
  42. inject(name => "IkiWiki::beautify_urlpath", call => \&mybeautify_urlpath);
  43. $origsubs{'targetpage'}=\&IkiWiki::targetpage;
  44. inject(name => "IkiWiki::targetpage", call => \&mytargetpage);
  45. } #}}}
  46. sub getsetup () { #{{{
  47. return
  48. plugin => {
  49. safe => 0,
  50. rebuild => 1, # format plugin & changes html filenames
  51. },
  52. po_master_language => {
  53. type => "string",
  54. example => {
  55. 'code' => 'en',
  56. 'name' => 'English'
  57. },
  58. description => "master language (non-PO files)",
  59. safe => 1,
  60. rebuild => 1,
  61. },
  62. po_slave_languages => {
  63. type => "string",
  64. example => {
  65. 'fr' => 'Français',
  66. 'es' => 'Castellano',
  67. 'de' => 'Deutsch'
  68. },
  69. description => "slave languages (PO files)",
  70. safe => 1,
  71. rebuild => 1,
  72. },
  73. po_translatable_pages => {
  74. type => "pagespec",
  75. example => "!*/Discussion",
  76. description => "PageSpec controlling which pages are translatable",
  77. link => "ikiwiki/PageSpec",
  78. safe => 1,
  79. rebuild => 1,
  80. },
  81. po_link_to => {
  82. type => "string",
  83. example => "current",
  84. description => "internal linking behavior (default/current/negotiated)",
  85. safe => 1,
  86. rebuild => 1,
  87. },
  88. } #}}}
  89. sub islanguagecode ($) { #{{{
  90. my $code=shift;
  91. return ($code =~ /^[a-z]{2}$/);
  92. } #}}}
  93. sub checkconfig () { #{{{
  94. foreach my $field (qw{po_master_language po_slave_languages}) {
  95. if (! exists $config{$field} || ! defined $config{$field}) {
  96. error(sprintf(gettext("Must specify %s"), $field));
  97. }
  98. }
  99. if (! (keys %{$config{po_slave_languages}})) {
  100. error(gettext("At least one slave language must be defined in po_slave_languages"));
  101. }
  102. map {
  103. islanguagecode($_)
  104. or error(sprintf(gettext("%s is not a valid language code"), $_));
  105. } ($config{po_master_language}{code}, keys %{$config{po_slave_languages}});
  106. if (! exists $config{po_translatable_pages} ||
  107. ! defined $config{po_translatable_pages}) {
  108. $config{po_translatable_pages}="";
  109. }
  110. if (! exists $config{po_link_to} ||
  111. ! defined $config{po_link_to}) {
  112. $config{po_link_to}='default';
  113. }
  114. elsif (! grep {
  115. $config{po_link_to} eq $_
  116. } ('default', 'current', 'negotiated')) {
  117. warn(sprintf(gettext('po_link_to=%s is not a valid setting, falling back to po_link_to=default'),
  118. $config{po_link_to}));
  119. $config{po_link_to}='default';
  120. }
  121. elsif ($config{po_link_to} eq "negotiated" && ! $config{usedirs}) {
  122. warn(gettext('po_link_to=negotiated requires usedirs to be enabled, falling back to po_link_to=default'));
  123. $config{po_link_to}='default';
  124. }
  125. push @{$config{wiki_file_prune_regexps}}, qr/\.pot$/;
  126. } #}}}
  127. sub potfile ($) { #{{{
  128. my $masterfile=shift;
  129. (my $name, my $dir, my $suffix) = fileparse($masterfile, qr/\.[^.]*/);
  130. $dir='' if $dir eq './';
  131. return File::Spec->catpath('', $dir, $name . ".pot");
  132. } #}}}
  133. sub pofile ($$) { #{{{
  134. my $masterfile=shift;
  135. my $lang=shift;
  136. (my $name, my $dir, my $suffix) = fileparse($masterfile, qr/\.[^.]*/);
  137. $dir='' if $dir eq './';
  138. return File::Spec->catpath('', $dir, $name . "." . $lang . ".po");
  139. } #}}}
  140. sub refreshpot ($) { #{{{
  141. my $masterfile=shift;
  142. my $potfile=potfile($masterfile);
  143. my %options = ("markdown" => (pagetype($masterfile) eq 'mdwn') ? 1 : 0);
  144. my $doc=Locale::Po4a::Chooser::new('text',%options);
  145. $doc->read($masterfile);
  146. $doc->{TT}{utf_mode} = 1;
  147. $doc->{TT}{file_in_charset} = 'utf-8';
  148. $doc->{TT}{file_out_charset} = 'utf-8';
  149. # let's cheat a bit to force porefs option to be passed to Locale::Po4a::Po;
  150. # this is undocument use of internal Locale::Po4a::TransTractor's data,
  151. # compulsory since this module prevents us from using the porefs option.
  152. my %po_options = ('porefs' => 'none');
  153. $doc->{TT}{po_out}=Locale::Po4a::Po->new(\%po_options);
  154. $doc->{TT}{po_out}->set_charset('utf-8');
  155. # do the actual work
  156. $doc->parse;
  157. IkiWiki::prep_writefile(basename($potfile),dirname($potfile));
  158. $doc->writepo($potfile);
  159. } #}}}
  160. sub refreshpofiles ($@) { #{{{
  161. my $masterfile=shift;
  162. my @pofiles=@_;
  163. my $potfile=potfile($masterfile);
  164. error("[po/refreshpofiles] POT file ($potfile) does not exist") unless (-e $potfile);
  165. foreach my $pofile (@pofiles) {
  166. IkiWiki::prep_writefile(basename($pofile),dirname($pofile));
  167. if (-e $pofile) {
  168. system("msgmerge", "-U", "--backup=none", $pofile, $potfile) == 0
  169. or error("[po/refreshpofiles:$pofile] failed to update");
  170. }
  171. else {
  172. File::Copy::syscopy($potfile,$pofile)
  173. or error("[po/refreshpofiles:$pofile] failed to copy the POT file");
  174. }
  175. }
  176. } #}}}
  177. sub needsbuild () { #{{{
  178. my $needsbuild=shift;
  179. # backup @needsbuild content so that change() can know whether
  180. # a given master page was rendered because its source file was changed
  181. @origneedsbuild=(@$needsbuild);
  182. # build %translations, using istranslation's side-effect
  183. map istranslation($_), (keys %pagesources);
  184. # make existing translations depend on the corresponding master page
  185. foreach my $master (keys %translations) {
  186. foreach my $slave (values %{$translations{$master}}) {
  187. add_depends($slave, $master);
  188. }
  189. }
  190. } #}}}
  191. sub mytargetpage ($$) { #{{{
  192. my $page=shift;
  193. my $ext=shift;
  194. if (istranslation($page)) {
  195. my ($masterpage, $lang) = ($page =~ /(.*)[.]([a-z]{2})$/);
  196. if (! $config{usedirs} || $masterpage eq 'index') {
  197. return $masterpage . "." . $lang . "." . $ext;
  198. }
  199. else {
  200. return $masterpage . "/index." . $lang . "." . $ext;
  201. }
  202. }
  203. elsif (istranslatable($page)) {
  204. if (! $config{usedirs} || $page eq 'index') {
  205. return $page . "." . $config{po_master_language}{code} . "." . $ext;
  206. }
  207. else {
  208. return $page . "/index." . $config{po_master_language}{code} . "." . $ext;
  209. }
  210. }
  211. return $origsubs{'targetpage'}->($page, $ext);
  212. } #}}}
  213. sub mybeautify_urlpath ($) { #{{{
  214. my $url=shift;
  215. my $res=$origsubs{'beautify_urlpath'}->($url);
  216. if ($config{po_link_to} eq "negotiated") {
  217. $res =~ s!/\Qindex.$config{po_master_language}{code}.$config{htmlext}\E$!/!;
  218. }
  219. return $res;
  220. } #}}}
  221. sub urlto_with_orig_beautiful_urlpath($$) { #{{{
  222. my $to=shift;
  223. my $from=shift;
  224. inject(name => "IkiWiki::beautify_urlpath", call => $origsubs{'beautify_urlpath'});
  225. my $res=urlto($to, $from);
  226. inject(name => "IkiWiki::beautify_urlpath", call => \&mybeautify_urlpath);
  227. return $res;
  228. } #}}}
  229. sub mybestlink ($$) { #{{{
  230. my $page=shift;
  231. my $link=shift;
  232. my $res=$origsubs{'bestlink'}->($page, $link);
  233. if (length $res) {
  234. if ($config{po_link_to} eq "current"
  235. && istranslatable($res)
  236. && istranslation($page)) {
  237. my ($masterpage, $curlang) = ($page =~ /(.*)[.]([a-z]{2})$/);
  238. return $res . "." . $curlang;
  239. }
  240. else {
  241. return $res;
  242. }
  243. }
  244. return "";
  245. } #}}}
  246. # We use filter to convert PO to the master page's format,
  247. # since the rest of ikiwiki should not work on PO files.
  248. sub filter (@) { #{{{
  249. my %params = @_;
  250. my $page = $params{page};
  251. my $destpage = $params{destpage};
  252. my $content = decode_utf8(encode_utf8($params{content}));
  253. return $content if ( ! istranslation($page)
  254. || ( exists $filtered{$page}{$destpage}
  255. && $filtered{$page}{$destpage} eq 1 ));
  256. # CRLF line terminators make poor Locale::Po4a feel bad
  257. $content=~s/\r\n/\n/g;
  258. # Implementation notes
  259. #
  260. # 1. Locale::Po4a reads/writes from/to files, and I'm too lazy
  261. # to learn how to disguise a variable as a file.
  262. # 2. There are incompatibilities between some File::Temp versions
  263. # (including 0.18, bundled with Lenny's perl-modules package)
  264. # and others (e.g. 0.20, previously present in the archive as
  265. # a standalone package): under certain circumstances, some
  266. # return a relative filename, whereas others return an absolute one;
  267. # we here use this module in a way that is at least compatible
  268. # with 0.18 and 0.20. Beware, hit'n'run refactorers!
  269. my $infile = new File::Temp(TEMPLATE => "ikiwiki-po-filter-in.XXXXXXXXXX",
  270. DIR => File::Spec->tmpdir,
  271. UNLINK => 1)->filename;
  272. my $outfile = new File::Temp(TEMPLATE => "ikiwiki-po-filter-out.XXXXXXXXXX",
  273. DIR => File::Spec->tmpdir,
  274. UNLINK => 1)->filename;
  275. writefile(basename($infile), File::Spec->tmpdir, $content);
  276. my ($masterpage, $lang) = ($page =~ /(.*)[.]([a-z]{2})$/);
  277. my $masterfile = srcfile($pagesources{$masterpage});
  278. my (@pos,@masters);
  279. push @pos,$infile;
  280. push @masters,$masterfile;
  281. my %options = (
  282. "markdown" => (pagetype($masterfile) eq 'mdwn') ? 1 : 0,
  283. );
  284. my $doc=Locale::Po4a::Chooser::new('text',%options);
  285. $doc->process(
  286. 'po_in_name' => \@pos,
  287. 'file_in_name' => \@masters,
  288. 'file_in_charset' => 'utf-8',
  289. 'file_out_charset' => 'utf-8',
  290. ) or error("[po/filter:$infile]: failed to translate");
  291. $doc->write($outfile) or error("[po/filter:$infile] could not write $outfile");
  292. $content = readfile($outfile) or error("[po/filter:$infile] could not read $outfile");
  293. # Unlinking should happen automatically, thanks to File::Temp,
  294. # but it does not work here, probably because of the way writefile()
  295. # and Locale::Po4a::write() work.
  296. unlink $infile, $outfile;
  297. $filtered{$page}{$destpage}=1;
  298. return $content;
  299. } #}}}
  300. sub htmlize (@) { #{{{
  301. my %params=@_;
  302. my $page = $params{page};
  303. my $content = $params{content};
  304. my ($masterpage, $lang) = ($page =~ /(.*)[.]([a-z]{2})$/);
  305. my $masterfile = srcfile($pagesources{$masterpage});
  306. # force content to be htmlize'd as if it was the same type as the master page
  307. return IkiWiki::htmlize($page, $page, pagetype($masterfile), $content);
  308. } #}}}
  309. sub percenttranslated ($) { #{{{
  310. my $page=shift;
  311. return gettext("N/A") unless (istranslation($page));
  312. my ($masterpage, $lang) = ($page =~ /(.*)[.]([a-z]{2})$/);
  313. my $file=srcfile($pagesources{$page});
  314. my $masterfile = srcfile($pagesources{$masterpage});
  315. my (@pos,@masters);
  316. push @pos,$file;
  317. push @masters,$masterfile;
  318. my %options = (
  319. "markdown" => (pagetype($masterfile) eq 'mdwn') ? 1 : 0,
  320. );
  321. my $doc=Locale::Po4a::Chooser::new('text',%options);
  322. $doc->process(
  323. 'po_in_name' => \@pos,
  324. 'file_in_name' => \@masters,
  325. 'file_in_charset' => 'utf-8',
  326. 'file_out_charset' => 'utf-8',
  327. ) or error("[po/percenttranslated:$file]: failed to translate");
  328. my ($percent,$hit,$queries) = $doc->stats();
  329. return $percent;
  330. } #}}}
  331. sub otherlanguages ($) { #{{{
  332. my $page=shift;
  333. my @ret;
  334. if (istranslatable($page)) {
  335. foreach my $lang (sort keys %{$translations{$page}}) {
  336. my $translation = $translations{$page}{$lang};
  337. push @ret, {
  338. url => urlto($translation, $page),
  339. code => $lang,
  340. language => $config{po_slave_languages}{$lang},
  341. percent => percenttranslated($translation),
  342. };
  343. }
  344. }
  345. elsif (istranslation($page)) {
  346. my ($masterpage, $curlang) = ($page =~ /(.*)[.]([a-z]{2})$/);
  347. push @ret, {
  348. url => urlto_with_orig_beautiful_urlpath($masterpage, $page),
  349. code => $config{po_master_language}{code},
  350. language => $config{po_master_language}{name},
  351. master => 1,
  352. };
  353. foreach my $lang (sort keys %{$translations{$masterpage}}) {
  354. push @ret, {
  355. url => urlto($translations{$masterpage}{$lang}, $page),
  356. code => $lang,
  357. language => $config{po_slave_languages}{$lang},
  358. percent => percenttranslated($translations{$masterpage}{$lang}),
  359. } unless ($lang eq $curlang);
  360. }
  361. }
  362. return @ret;
  363. } #}}}
  364. sub pagetemplate (@) { #{{{
  365. my %params=@_;
  366. my $page=$params{page};
  367. my $destpage=$params{destpage};
  368. my $template=$params{template};
  369. my ($masterpage, $lang) = ($page =~ /(.*)[.]([a-z]{2})$/) if istranslation($page);
  370. if (istranslation($page) && $template->query(name => "percenttranslated")) {
  371. $template->param(percenttranslated => percenttranslated($page));
  372. }
  373. if ($template->query(name => "istranslation")) {
  374. $template->param(istranslation => istranslation($page));
  375. }
  376. if ($template->query(name => "istranslatable")) {
  377. $template->param(istranslatable => istranslatable($page));
  378. }
  379. if ($template->query(name => "otherlanguages")) {
  380. $template->param(otherlanguages => [otherlanguages($page)]);
  381. if (istranslatable($page)) {
  382. foreach my $translation (values %{$translations{$page}}) {
  383. add_depends($page, $translation);
  384. }
  385. }
  386. elsif (istranslation($page)) {
  387. add_depends($page, $masterpage);
  388. foreach my $translation (values %{$translations{$masterpage}}) {
  389. add_depends($page, $translation);
  390. }
  391. }
  392. }
  393. # Rely on IkiWiki::Render's genpage() to decide wether
  394. # a discussion link should appear on $page; this is not
  395. # totally accurate, though: some broken links may be generated
  396. # when cgiurl is disabled.
  397. # This compromise avoids some code duplication, and will probably
  398. # prevent future breakage when ikiwiki internals change.
  399. # Known limitations are preferred to future random bugs.
  400. if ($template->param('discussionlink') && istranslation($page)) {
  401. $template->param('discussionlink' => htmllink(
  402. $page,
  403. $destpage,
  404. $masterpage . '/' . gettext("Discussion"),
  405. noimageinline => 1,
  406. forcesubpage => 0,
  407. linktext => gettext("Discussion"),
  408. ));
  409. }
  410. # remove broken parentlink to ./index.html on home page's translations
  411. if ($template->param('parentlinks')
  412. && istranslation($page)
  413. && $masterpage eq "index") {
  414. $template->param('parentlinks' => []);
  415. }
  416. } # }}}
  417. sub change(@) { #{{{
  418. my @rendered=@_;
  419. my $updated_po_files=0;
  420. # Refresh/create POT and PO files as needed.
  421. foreach my $page (map pagename($_), @rendered) {
  422. next unless istranslatable($page);
  423. my $file=srcfile($pagesources{$page});
  424. my $updated_pot_file=0;
  425. if ((grep { $_ eq $pagesources{$page} } @origneedsbuild)
  426. || ! -e potfile($file)) {
  427. refreshpot($file);
  428. $updated_pot_file=1;
  429. }
  430. my @pofiles;
  431. foreach my $lang (keys %{$config{po_slave_languages}}) {
  432. my $pofile=pofile($file, $lang);
  433. if ($updated_pot_file || ! -e $pofile) {
  434. push @pofiles, $pofile;
  435. }
  436. }
  437. if (@pofiles) {
  438. refreshpofiles($file, @pofiles);
  439. map { IkiWiki::rcs_add($_); } @pofiles if ($config{rcs});
  440. $updated_po_files=1;
  441. }
  442. }
  443. if ($updated_po_files) {
  444. # Check staged changes in.
  445. if ($config{rcs}) {
  446. IkiWiki::disable_commit_hook();
  447. IkiWiki::rcs_commit_staged(gettext("updated PO files"),
  448. "IkiWiki::Plugin::po::change", "127.0.0.1");
  449. IkiWiki::enable_commit_hook();
  450. IkiWiki::rcs_update();
  451. }
  452. # Reinitialize module's private variables.
  453. undef %filtered;
  454. undef %translations;
  455. # Trigger a wiki refresh.
  456. require IkiWiki::Render;
  457. IkiWiki::refresh();
  458. IkiWiki::saveindex();
  459. }
  460. } #}}}
  461. sub editcontent () { #{{{
  462. my %params=@_;
  463. # as we're previewing or saving a page, the content may have
  464. # changed, so tell the next filter() invocation it must not be lazy
  465. if (exists $filtered{$params{page}}{$params{page}}) {
  466. delete $filtered{$params{page}}{$params{page}};
  467. }
  468. return $params{content};
  469. } #}}}
  470. sub istranslatable ($) { #{{{
  471. my $page=shift;
  472. my $file=$pagesources{$page};
  473. if (! defined $file
  474. || (defined pagetype($file) && pagetype($file) eq 'po')
  475. || $file =~ /\.pot$/) {
  476. return 0;
  477. }
  478. return pagespec_match($page, $config{po_translatable_pages});
  479. } #}}}
  480. sub _istranslation ($) { #{{{
  481. my $page=shift;
  482. my $file=$pagesources{$page};
  483. if (! defined $file) {
  484. return IkiWiki::FailReason->new("no file specified");
  485. }
  486. if (! defined $file
  487. || ! defined pagetype($file)
  488. || ! pagetype($file) eq 'po'
  489. || $file =~ /\.pot$/) {
  490. return 0;
  491. }
  492. my ($masterpage, $lang) = ($page =~ /(.*)[.]([a-z]{2})$/);
  493. if (! defined $masterpage || ! defined $lang
  494. || ! (length($masterpage) > 0) || ! (length($lang) > 0)
  495. || ! defined $pagesources{$masterpage}
  496. || ! defined $config{po_slave_languages}{$lang}) {
  497. return 0;
  498. }
  499. return istranslatable($masterpage);
  500. } #}}}
  501. sub istranslation ($) { #{{{
  502. my $page=shift;
  503. if (_istranslation($page)) {
  504. my ($masterpage, $lang) = ($page =~ /(.*)[.]([a-z]{2})$/);
  505. $translations{$masterpage}{$lang}=$page unless exists $translations{$masterpage}{$lang};
  506. return 1;
  507. }
  508. return 0;
  509. } #}}}
  510. package IkiWiki::PageSpec;
  511. use warnings;
  512. use strict;
  513. use IkiWiki 2.00;
  514. sub match_istranslation ($;@) { #{{{
  515. my $page=shift;
  516. if (IkiWiki::Plugin::po::istranslation($page)) {
  517. return IkiWiki::SuccessReason->new("is a translation page");
  518. }
  519. else {
  520. return IkiWiki::FailReason->new("is not a translation page");
  521. }
  522. } #}}}
  523. sub match_istranslatable ($;@) { #{{{
  524. my $page=shift;
  525. if (IkiWiki::Plugin::po::istranslatable($page)) {
  526. return IkiWiki::SuccessReason->new("is set as translatable in po_translatable_pages");
  527. }
  528. else {
  529. return IkiWiki::FailReason->new("is not set as translatable in po_translatable_pages");
  530. }
  531. } #}}}
  532. sub match_lang ($$;@) { #{{{
  533. my $page=shift;
  534. my $wanted=shift;
  535. my $regexp=IkiWiki::glob2re($wanted);
  536. my $lang;
  537. my $masterpage;
  538. if (IkiWiki::Plugin::po::istranslation($page)) {
  539. ($masterpage, $lang) = ($page =~ /(.*)[.]([a-z]{2})$/);
  540. }
  541. else {
  542. $lang = $config{po_master_language}{code};
  543. }
  544. if ($lang!~/^$regexp$/i) {
  545. return IkiWiki::FailReason->new("file language is $lang, not $wanted");
  546. }
  547. else {
  548. return IkiWiki::SuccessReason->new("file language is $wanted");
  549. }
  550. } #}}}
  551. sub match_currentlang ($$;@) { #{{{
  552. my $page=shift;
  553. shift;
  554. my %params=@_;
  555. my ($currentmasterpage, $currentlang, $masterpage, $lang);
  556. return IkiWiki::FailReason->new("no location provided") unless exists $params{location};
  557. if (IkiWiki::Plugin::po::istranslation($params{location})) {
  558. ($currentmasterpage, $currentlang) = ($params{location} =~ /(.*)[.]([a-z]{2})$/);
  559. }
  560. else {
  561. $currentlang = $config{po_master_language}{code};
  562. }
  563. if (IkiWiki::Plugin::po::istranslation($page)) {
  564. ($masterpage, $lang) = ($page =~ /(.*)[.]([a-z]{2})$/);
  565. }
  566. else {
  567. $lang = $config{po_master_language}{code};
  568. }
  569. if ($lang eq $currentlang) {
  570. return IkiWiki::SuccessReason->new("file language is the same as current one, i.e. $currentlang");
  571. }
  572. else {
  573. return IkiWiki::FailReason->new("file language is $lang, whereas current language is $currentlang");
  574. }
  575. } #}}}
  576. 1