From 42b4abee1d14fe1c571b2324f86e283d3db4d7e6 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 5 Nov 2008 01:38:36 -0500 Subject: [PATCH 01/14] use error for two messages --- IkiWiki/Plugin/inline.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 1b1ca2ce2..7fe5a4dcf 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -201,7 +201,7 @@ sub preprocess_inline (@) { #{{{ @list=sort { $pagectime{$b} <=> $pagectime{$a} } @list; } else { - return sprintf(gettext("unknown sort type %s"), $params{sort}); + error sprintf(gettext("unknown sort type %s"), $params{sort}); } if (yesno($params{reverse})) { @@ -298,7 +298,7 @@ sub preprocess_inline (@) { #{{{ require HTML::Template; my @params=IkiWiki::template_params($params{template}.".tmpl", blind_cache => 1); if (! @params) { - return sprintf(gettext("nonexistant template %s"), $params{template}); + error sprintf(gettext("nonexistant template %s"), $params{template}); } my $template=HTML::Template->new(@params) unless $raw; From ab729c78b2c3f597d460adc63ab6c832059bafd2 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 5 Nov 2008 13:21:16 -0500 Subject: [PATCH 02/14] add a more useful example of a relative date ;-) --- doc/plugins/relativedate.mdwn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/plugins/relativedate.mdwn b/doc/plugins/relativedate.mdwn index 32f8c798b..3ada0864b 100644 --- a/doc/plugins/relativedate.mdwn +++ b/doc/plugins/relativedate.mdwn @@ -13,4 +13,4 @@ If this plugin is enabled, you may also add relative dates to pages in the wiki, by using html elements in the "relativedate" class. For example, this will display as a relative date: - Fri Oct 17 18:36:13 EDT 2008 + Tue Jan 20 12:00:00 EDT 2009 From f258902a2146e968aecc80ead6f74102c0418b66 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 5 Nov 2008 13:30:26 -0500 Subject: [PATCH 03/14] response --- doc/plugins/img/discussion.mdwn | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/plugins/img/discussion.mdwn b/doc/plugins/img/discussion.mdwn index 5bf340c56..e1bb2d15b 100644 --- a/doc/plugins/img/discussion.mdwn +++ b/doc/plugins/img/discussion.mdwn @@ -7,3 +7,6 @@ instead of linking to the PNG image file. --[[tschwinge]] > Done, use link=somepage --[[Joey]] It would be handy if the `class` and `id` tags were passed through to the surrounding `table` in the case of `caption` being present. Would this break anything? --[[neale]] + +> Seems unlikely to break *too* much. I can imagine css that styles the img +> unexpectedly applying the table. --[[Joey]] From c5c0f0816acb0a841ff2f79ad1699054d3d222c7 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 5 Nov 2008 13:54:25 -0500 Subject: [PATCH 04/14] suggest po4a for po plugin --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/control b/debian/control index fdf2a3a36..04283532b 100644 --- a/debian/control +++ b/debian/control @@ -14,7 +14,7 @@ Package: ikiwiki Architecture: all Depends: ${perl:Depends}, markdown | libtext-markdown-perl, libhtml-scrubber-perl, libhtml-template-perl, libhtml-parser-perl, liburi-perl Recommends: gcc | c-compiler, libc6-dev | libc-dev, subversion | git-core (>= 1:1.5.0) | tla | bzr (>= 0.91) | mercurial | monotone (>= 0.38), libxml-simple-perl, libnet-openid-consumer-perl, liblwpx-paranoidagent-perl, libtimedate-perl, libcgi-formbuilder-perl (>= 3.05), libcgi-session-perl (>= 4.14-1), libmail-sendmail-perl, libauthen-passphrase-perl -Suggests: viewvc | gitweb | viewcvs, libsearch-xapian-perl, xapian-omega (>= 1.0.5), librpc-xml-perl, libtext-wikiformat-perl, python, python-docutils, polygen, tidy, libxml-feed-perl, libmailtools-perl, perlmagick, libfile-mimeinfo-perl, libcrypt-ssleay-perl, liblocale-gettext-perl (>= 1.05-1), libtext-typography-perl, libtext-csv-perl, libdigest-sha1-perl, graphviz, libnet-amazon-s3-perl, sparkline-php, texlive, dvipng +Suggests: viewvc | gitweb | viewcvs, libsearch-xapian-perl, xapian-omega (>= 1.0.5), librpc-xml-perl, libtext-wikiformat-perl, python, python-docutils, polygen, tidy, libxml-feed-perl, libmailtools-perl, perlmagick, libfile-mimeinfo-perl, libcrypt-ssleay-perl, liblocale-gettext-perl (>= 1.05-1), libtext-typography-perl, libtext-csv-perl, libdigest-sha1-perl, graphviz, libnet-amazon-s3-perl, sparkline-php, texlive, dvipng, po4a Conflicts: ikiwiki-plugin-table Replaces: ikiwiki-plugin-table Provides: ikiwiki-plugin-table From f2dd41d1e86dd9be38e48a7ec93b500c037e73c4 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 5 Nov 2008 13:55:32 -0500 Subject: [PATCH 05/14] add a link to pages for enhanced pagespecs --- doc/ikiwiki/pagespec.mdwn | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/ikiwiki/pagespec.mdwn b/doc/ikiwiki/pagespec.mdwn index c78666c40..176228e4b 100644 --- a/doc/ikiwiki/pagespec.mdwn +++ b/doc/ikiwiki/pagespec.mdwn @@ -47,6 +47,8 @@ Some more elaborate limits can be added to what matches using these functions: wiki admins. * "`ip(address)`" - tests whether a modification is being made from the specified IP address. +* Some additional special-purpose limits may be enabled, for matching + [[attachments|attachment]] and [[translations|po]]. For example, to match all pages in a blog that link to the page about music and were written in 2005: From 9bedf53c0ffee098cea02c7acc2c430db18b7841 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 5 Nov 2008 13:57:48 -0500 Subject: [PATCH 06/14] another reason to require rebuilds (and not be marked safe) the plugin changes html filenames, so requiring a manual transition to enable --- IkiWiki/Plugin/po.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 9dda8c0db..35eed6118 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -47,7 +47,7 @@ sub getsetup () { #{{{ return plugin => { safe => 0, - rebuild => 1, # format plugin + rebuild => 1, # format plugin & changes html filenames }, po_master_language => { type => "string", From b76ee8a96dbf64a4231f749fc9c233518f367ecd Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 5 Nov 2008 14:22:02 -0500 Subject: [PATCH 07/14] minor wording improvements/changes --- doc/ikiwiki/pagespec/po.mdwn | 2 +- doc/plugins/po.mdwn | 22 +++++++++------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/doc/ikiwiki/pagespec/po.mdwn b/doc/ikiwiki/pagespec/po.mdwn index 2edfaa0c1..60c344689 100644 --- a/doc/ikiwiki/pagespec/po.mdwn +++ b/doc/ikiwiki/pagespec/po.mdwn @@ -12,5 +12,5 @@ wiki: * "`currentlang()`" - Tests whether a page is written in the same language as the current page. -Note: every non-PO page is considered to be written in +Note: every non-po page is considered to be written in `po_master_language`, as specified in `ikiwiki.setup`. diff --git a/doc/plugins/po.mdwn b/doc/plugins/po.mdwn index fe6b6b562..2463680f5 100644 --- a/doc/plugins/po.mdwn +++ b/doc/plugins/po.mdwn @@ -13,7 +13,7 @@ A language is chosen as the "master" one, and any other supported language is a "slave" one. A page written in the "master" language is a "master" page. It can be -of any page type supported by ikiwiki, but PO. It does not have to be +of any page type supported by ikiwiki, except `po`. It does not have to be named a special way: migration to this plugin does not imply any page renaming work. @@ -22,7 +22,7 @@ English; if `usedirs` is enabled, it is rendered as `bla/page/index.en.html`, else as `bla/page.en.html`. Any translation of a "master" page into a "slave" language is called -a "slave" page; it is written in the gettext PO format. PO is now +a "slave" page; it is written in the gettext PO format. `po` is now a page type supported by ikiwiki. Example: `bla/page.fr.po` is the PO "message catalog" used to @@ -56,9 +56,8 @@ The `po_translatable_pages` setting configures what pages are translatable. It is a [[ikiwiki/PageSpec]], so you have lots of control over what kind of pages are translatable. -The PO translations files are anyway not considered as being -translatable, so you don't need to worry about excluding them -explicitly from this [[ikiwiki/PageSpec]]. +The `.po` files are not considered as being translatable, so you don't need to +worry about excluding them explicitly from this [[ikiwiki/PageSpec]]. Internal links -------------- @@ -180,17 +179,14 @@ Additional PageSpec tests This plugin enhances the regular [[ikiwiki/PageSpec]] syntax with some additional tests that are documented [[here|ikiwiki/pagespec/po]]. -Automatic PO files update -------------------------- +Automatic PO file update +------------------------ Committing changes to a "master" page: -1. updates the POT file and the PO files for the supported languages - (this is done in the `needsbuild` hook); the updated PO files are - then put under version control -2. triggers a refresh of the corresponding HTML slave pages (this is - achieved by making any "slave" page dependent on the corresponding - "master" page, in the `needsbuild` hook) +1. updates the POT file and the PO files for the supported languages; + the updated PO files are then put under version control +2. triggers a refresh of the corresponding HTML slave pages Also, when the plugin has just been enabled, or when a page has just been declared as being translatable, the needed POT and PO files are From 7e95723dadfe2a11fcd2463f2e8adf579fdc64db Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 5 Nov 2008 14:45:45 -0500 Subject: [PATCH 08/14] avoid hitting the shell with system() --- IkiWiki/Plugin/po.pm | 3 +-- doc/plugins/po.mdwn | 10 +++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 35eed6118..b8c218c5a 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -149,8 +149,7 @@ sub refreshpofiles ($@) { #{{{ foreach my $pofile (@pofiles) { if (-e $pofile) { - my $cmd = "msgmerge -U --backup=none $pofile $potfile"; - system ($cmd) == 0 + system("msgmerge", "-U", "--backup=none", $pofile, $potfile) == 0 or error("[po/refreshpofiles:$pofile] failed to update"); } else { diff --git a/doc/plugins/po.mdwn b/doc/plugins/po.mdwn index 2463680f5..7ac1b3f0f 100644 --- a/doc/plugins/po.mdwn +++ b/doc/plugins/po.mdwn @@ -205,7 +205,7 @@ Translating One can edit the PO files using ikiwiki's CGI (a message-by-message interface could also be implemented at some point). -If [[tips/untrusted_git_push]] is setup, one can edit the PO files in her +If [[tips/untrusted_git_push]] is setup, one can edit the PO files in one's preferred `$EDITOR`, without needing to be online. TODO @@ -267,6 +267,14 @@ by something like [[todo/using_meta_titles_for_parentlinks]]. Which configuration settings are safe enough for websetup? +> I see no problems with `po_master_language` and `po_slave_languages` +> (assuming websetup handles the hashes correctly). Would not hurt to check +> that the values of these are legal language codes, in `checkconfig`. +> `po_translatable_pages` seems entirely safe. `po_link_to` w/o usedirs +> causes ikiwiki to error out. If it were changed to fall back to a safe +> setting in this case rather than error, it would be safe. +> --[[Joey]] + ### parentlinks When the wiki home page is translatable, the parentlinks plugin sets From 6fbe214d91ca9be37d149a1e5ba11590490959aa Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 5 Nov 2008 14:47:50 -0500 Subject: [PATCH 09/14] fixed one security problem, two more need review --- doc/plugins/po.mdwn | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/plugins/po.mdwn b/doc/plugins/po.mdwn index 7ac1b3f0f..ba293f262 100644 --- a/doc/plugins/po.mdwn +++ b/doc/plugins/po.mdwn @@ -227,8 +227,14 @@ Security checks - `refreshpofiles` uses `system()`, whose args have to be checked more thoroughly to prevent any security issue (command injection, etc.). + > Always pass `system()` a list of parameters to avoid the shell. + > I've checked in a change fixing that. --[[Joey]] - `refreshpofiles` and `refreshpot` create new files; this may need some checks, e.g. using `IkiWiki::prep_writefile()` +- Can any sort of directives be put in po files that will + cause mischief (ie, include other files, run commands, crash gettext, + whatever). +- Any security issues on running po4a on untrusted content? gettext/po4a rough corners -------------------------- From b609ae76edf4d18f87643dde3cb6940f8b4f33f1 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 5 Nov 2008 14:58:35 -0500 Subject: [PATCH 10/14] response --- doc/plugins/po.mdwn | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/plugins/po.mdwn b/doc/plugins/po.mdwn index ba293f262..6d468f07e 100644 --- a/doc/plugins/po.mdwn +++ b/doc/plugins/po.mdwn @@ -231,6 +231,10 @@ Security checks > I've checked in a change fixing that. --[[Joey]] - `refreshpofiles` and `refreshpot` create new files; this may need some checks, e.g. using `IkiWiki::prep_writefile()` + > Yes, it would be ideal to call `prep_writefile` on each file + > that they write, beforehand. This way you'd avoid symlink attacks etc to the + > generated po/pot files. I haven't done it, but it seems pretty trivial. + > --[[Joey]] - Can any sort of directives be put in po files that will cause mischief (ie, include other files, run commands, crash gettext, whatever). From fe580240d40b17db3488c22057fdda62ae8a6f85 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 5 Nov 2008 15:02:22 -0500 Subject: [PATCH 11/14] need license --- doc/plugins/po.mdwn | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/plugins/po.mdwn b/doc/plugins/po.mdwn index 6d468f07e..a2e7b18e3 100644 --- a/doc/plugins/po.mdwn +++ b/doc/plugins/po.mdwn @@ -298,6 +298,11 @@ If a given translatable `sourcepage.mdwn` links to \[[destpage]], `sourcepage.LL.po` also link to \[[destpage]], and the latter has the master page *and* all its translations listed in the backlinks. +### license + +> Could you please put a copyright and license on po.pm? I assume it's +> GPLed as it's based on po4a-translate. --[[Joey]] + Translation quality assurance ----------------------------- From 9b16e7f148c36c61e511bcc787d3192b7bb1c3c5 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 5 Nov 2008 15:09:04 -0500 Subject: [PATCH 12/14] minor layout changes --- IkiWiki/Plugin/po.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index b8c218c5a..4bac37656 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -31,7 +31,7 @@ $origsubs{'bestlink'}=\&IkiWiki::bestlink; $origsubs{'beautify_urlpath'}=\&IkiWiki::beautify_urlpath; $origsubs{'targetpage'}=\&IkiWiki::targetpage; -sub import { +sub import { #{{{ hook(type => "getsetup", id => "po", call => \&getsetup); hook(type => "checkconfig", id => "po", call => \&checkconfig); hook(type => "needsbuild", id => "po", call => \&needsbuild); @@ -41,7 +41,7 @@ sub import { inject(name => "IkiWiki::bestlink", call => \&mybestlink); inject(name => "IkiWiki::beautify_urlpath", call => \&mybeautify_urlpath); inject(name => "IkiWiki::targetpage", call => \&mytargetpage); -} +} #}}} sub getsetup () { #{{{ return @@ -289,8 +289,8 @@ sub filter (@) { #{{{ my $destpage = $params{destpage}; my $content = decode_utf8(encode_utf8($params{content})); - # decide if this is a PO file that should be converted into a translated document, - # and perform various sanity checks + # decide if this is a PO file that should be converted into a + # translated document, and perform various sanity checks if (! istranslation($page) || $filtered{$page}{$destpage}) { return $content; } From ae37bca0e2593f18ed7f6ecb129e2d5bb3c113cc Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 5 Nov 2008 15:09:54 -0500 Subject: [PATCH 13/14] backup refs to injected subs later In case two plugins both inject replacements for these subs, backup the ref just before injecting to make sure the most recent version is seen. --- IkiWiki/Plugin/po.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 4bac37656..466ffd0b8 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -27,9 +27,6 @@ memoize("percenttranslated"); # backup references to subs that will be overriden my %origsubs; -$origsubs{'bestlink'}=\&IkiWiki::bestlink; -$origsubs{'beautify_urlpath'}=\&IkiWiki::beautify_urlpath; -$origsubs{'targetpage'}=\&IkiWiki::targetpage; sub import { #{{{ hook(type => "getsetup", id => "po", call => \&getsetup); @@ -38,8 +35,12 @@ sub import { #{{{ hook(type => "filter", id => "po", call => \&filter); hook(type => "htmlize", id => "po", call => \&htmlize); hook(type => "pagetemplate", id => "po", call => \&pagetemplate); + + $origsubs{'bestlink'}=\&IkiWiki::bestlink; inject(name => "IkiWiki::bestlink", call => \&mybestlink); + $origsubs{'beautify_urlpath'}=\&IkiWiki::beautify_urlpath; inject(name => "IkiWiki::beautify_urlpath", call => \&mybeautify_urlpath); + $origsubs{'targetpage'}=\&IkiWiki::targetpage; inject(name => "IkiWiki::targetpage", call => \&mytargetpage); } #}}} From 17bd930bc9f4192e084a223cf57af94680741853 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 5 Nov 2008 15:18:07 -0500 Subject: [PATCH 14/14] first pass over code Only change of note is quoting some strings in a regexp, just in case (also avoids the . matching any character!) Mostly whitespace changes of no consequence. --- IkiWiki/Plugin/po.pm | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 466ffd0b8..ac56041cf 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -96,11 +96,11 @@ sub checkconfig () { #{{{ } if (! exists $config{po_link_to} || ! defined $config{po_link_to}) { - $config{po_link_to}="default"; + $config{po_link_to}="default"; } if (! exists $config{po_translatable_pages} || ! defined $config{po_translatable_pages}) { - $config{po_translatable_pages}=""; + $config{po_translatable_pages}=""; } if ($config{po_link_to} eq "negotiated" && ! $config{usedirs}) { error(gettext("po_link_to=negotiated requires usedirs to be set")); @@ -110,6 +110,7 @@ sub checkconfig () { #{{{ sub potfile ($) { #{{{ my $masterfile=shift; + (my $name, my $dir, my $suffix) = fileparse($masterfile, qr/\.[^.]*/); return File::Spec->catfile($dir, $name . ".pot"); } #}}} @@ -117,12 +118,14 @@ sub potfile ($) { #{{{ sub pofile ($$) { #{{{ my $masterfile=shift; my $lang=shift; + (my $name, my $dir, my $suffix) = fileparse($masterfile, qr/\.[^.]*/); return File::Spec->catfile($dir, $name . "." . $lang . ".po"); } #}}} sub refreshpot ($) { #{{{ my $masterfile=shift; + my $potfile=potfile($masterfile); my %options = ("markdown" => (pagetype($masterfile) eq 'mdwn') ? 1 : 0); my $doc=Locale::Po4a::Chooser::new('text',%options); @@ -211,7 +214,6 @@ sub needsbuild () { #{{{ } } - # make existing translations depend on the corresponding master page foreach my $master (keys %translations) { foreach my $slave (values %{$translations{$master}}) { @@ -246,9 +248,10 @@ sub mytargetpage ($$) { #{{{ sub mybeautify_urlpath ($) { #{{{ my $url=shift; + my $res=$origsubs{'beautify_urlpath'}->($url); if ($config{po_link_to} eq "negotiated") { - $res =~ s!/index.$config{po_master_language}{code}.$config{htmlext}$!/!; + $res =~ s!/\Qindex.$config{po_master_language}{code}.$config{htmlext}\E$!/!; } return $res; } #}}} @@ -267,6 +270,7 @@ sub urlto_with_orig_beautiful_urlpath($$) { #{{{ sub mybestlink ($$) { #{{{ my $page=shift; my $link=shift; + my $res=$origsubs{'bestlink'}->($page, $link); if (length $res) { if ($config{po_link_to} eq "current" @@ -286,6 +290,7 @@ sub mybestlink ($$) { #{{{ # since other plugins should not work on PO files sub filter (@) { #{{{ my %params = @_; + my $page = $params{page}; my $destpage = $params{destpage}; my $content = decode_utf8(encode_utf8($params{content})); @@ -303,8 +308,8 @@ sub filter (@) { #{{{ push @pos,$file; push @masters,$masterfile; my %options = ( - "markdown" => (pagetype($masterfile) eq 'mdwn') ? 1 : 0, - ); + "markdown" => (pagetype($masterfile) eq 'mdwn') ? 1 : 0, + ); my $doc=Locale::Po4a::Chooser::new('text',%options); $doc->process( 'po_in_name' => \@pos, @@ -314,6 +319,7 @@ sub filter (@) { #{{{ ) or error("[po/filter:$file]: failed to translate"); my $tmpfh = File::Temp->new(TEMPLATE => "/tmp/ikiwiki-po-filter-out.XXXXXXXXXX"); my $tmpout = $tmpfh->filename; + # XXX is there any way to avoid the useless write to a temp file? --Joey $doc->write($tmpout) or error("[po/filter:$file] could not write $tmpout"); $content = readfile($tmpout) or error("[po/filter:$file] could not read $tmpout"); $filtered{$page}{$destpage}=1; @@ -322,6 +328,7 @@ sub filter (@) { #{{{ sub htmlize (@) { #{{{ my %params=@_; + my $page = $params{page}; my $content = $params{content}; my ($masterpage, $lang) = ($page =~ /(.*)[.]([a-z]{2})$/); @@ -333,7 +340,8 @@ sub htmlize (@) { #{{{ sub percenttranslated ($) { #{{{ my $page=shift; - return "N/A" unless (istranslation($page)); + + return gettext("N/A") unless (istranslation($page)); my ($masterpage, $lang) = ($page =~ /(.*)[.]([a-z]{2})$/); my $file=srcfile($pagesources{$page}); my $masterfile = srcfile($pagesources{$masterpage}); @@ -341,8 +349,8 @@ sub percenttranslated ($) { #{{{ push @pos,$file; push @masters,$masterfile; my %options = ( - "markdown" => (pagetype($masterfile) eq 'mdwn') ? 1 : 0, - ); + "markdown" => (pagetype($masterfile) eq 'mdwn') ? 1 : 0, + ); my $doc=Locale::Po4a::Chooser::new('text',%options); $doc->process( 'po_in_name' => \@pos, @@ -356,6 +364,7 @@ sub percenttranslated ($) { #{{{ sub otherlanguages ($) { #{{{ my $page=shift; + my @ret; if (istranslatable($page)) { foreach my $lang (sort keys %{$translations{$page}}) { @@ -391,6 +400,7 @@ sub otherlanguages ($) { #{{{ sub pagetemplate (@) { #{{{ my %params=@_; my $page=$params{page}; + my $destpage=$params{destpage}; my $template=$params{template}; @@ -440,6 +450,7 @@ sub pagetemplate (@) { #{{{ sub istranslatable ($) { #{{{ my $page=shift; + my $file=$pagesources{$page}; if (! defined $file @@ -452,6 +463,7 @@ sub istranslatable ($) { #{{{ sub _istranslation ($) { #{{{ my $page=shift; + my $file=$pagesources{$page}; if (! defined $file) { return IkiWiki::FailReason->new("no file specified"); @@ -477,6 +489,7 @@ sub _istranslation ($) { #{{{ sub istranslation ($) { #{{{ my $page=shift; + if (_istranslation($page)) { my ($masterpage, $lang) = ($page =~ /(.*)[.]([a-z]{2})$/); $translations{$masterpage}{$lang}=$page unless exists $translations{$masterpage}{$lang}; @@ -492,6 +505,7 @@ use IkiWiki 2.00; sub match_istranslation ($;@) { #{{{ my $page=shift; + if (IkiWiki::Plugin::po::istranslation($page)) { return IkiWiki::SuccessReason->new("is a translation page"); } @@ -502,6 +516,7 @@ sub match_istranslation ($;@) { #{{{ sub match_istranslatable ($;@) { #{{{ my $page=shift; + if (IkiWiki::Plugin::po::istranslatable($page)) { return IkiWiki::SuccessReason->new("is set as translatable in po_translatable_pages"); } @@ -513,6 +528,7 @@ sub match_istranslatable ($;@) { #{{{ sub match_lang ($$;@) { #{{{ my $page=shift; my $wanted=shift; + my $regexp=IkiWiki::glob2re($wanted); my $lang; my $masterpage; @@ -534,6 +550,7 @@ sub match_lang ($$;@) { #{{{ sub match_currentlang ($$;@) { #{{{ my $page=shift; + shift; my %params=@_; my ($currentmasterpage, $currentlang, $masterpage, $lang);