summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2008-10-14 16:36:01 +0200
committerintrigeri <intrigeri@boum.org>2008-10-18 15:49:11 +0200
commitd5b5cfb8e42b7fed8a2a777c542461c0bcebf5ea (patch)
tree995a7f882fa17b666543ec4b72e9bbd67bb303af /IkiWiki/Plugin
parentbd237d48cfd8b61639c2ccb41fb4ed27afde478e (diff)
po plugin: refresh POT files when a master page is updated
Signed-off-by: intrigeri <intrigeri@boum.org>
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r--IkiWiki/Plugin/po.pm19
1 files changed, 19 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm
index 997f17fb3..1cab44dde 100644
--- a/IkiWiki/Plugin/po.pm
+++ b/IkiWiki/Plugin/po.pm
@@ -9,6 +9,8 @@ use strict;
use IkiWiki 2.00;
use Encode;
use Locale::Po4a::Chooser;
+use File::Basename;
+use File::Spec;
use File::Temp;
use Memoize;
@@ -92,6 +94,20 @@ sub checkconfig () { #{{{
push @{$config{wiki_file_prune_regexps}}, qr/\.pot$/;
} #}}}
+sub refreshpot ($) { #{{{
+ my $masterfile=shift;
+ (my $name, my $dir, my $suffix) = fileparse($masterfile, qr/\.[^.]*/);
+ my $potfile=File::Spec->catfile($dir, $name . ".pot");
+ my %options = ("markdown" => (pagetype($masterfile) eq 'mdwn') ? 1 : 0);
+ my $doc=Locale::Po4a::Chooser::new('text',%options);
+ $doc->read($masterfile);
+ $doc->{TT}{utf_mode} = 1;
+ $doc->{TT}{file_in_charset} = 'utf-8';
+ $doc->{TT}{file_out_charset} = 'utf-8';
+ $doc->parse or error("[po/refreshpot:$masterfile]: failed to parse");
+ $doc->writepo($potfile);
+} #}}}
+
sub needsbuild () { #{{{
my $needsbuild=shift;
@@ -100,6 +116,9 @@ sub needsbuild () { #{{{
istranslation($page);
}
+ foreach my $file (@$needsbuild) {
+ refreshpot(srcfile($file)) if (istranslatable(pagename($file)));
+ }
} #}}}
sub targetpage (@) { #{{{