summaryrefslogtreecommitdiff
path: root/po/po2wiki
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2009-07-20 07:20:43 +0200
committerJoey Hess <joey@gnu.kitenet.net>2009-07-20 07:20:43 +0200
commitbe30203459f6994f650ed56b9f7da88b8c98c137 (patch)
tree1f97d8f50e6f5a05c3b7edb184c06f56145acba1 /po/po2wiki
parente6709f6677f037097744a07cc9c3b58db4fd4595 (diff)
parenta7b813182df7d18a0d1bf2fb28b3ee4c069c86e9 (diff)
Merge branch 'master' into integration
Diffstat (limited to 'po/po2wiki')
-rwxr-xr-xpo/po2wiki41
1 files changed, 41 insertions, 0 deletions
diff --git a/po/po2wiki b/po/po2wiki
new file mode 100755
index 000000000..6b84f7d54
--- /dev/null
+++ b/po/po2wiki
@@ -0,0 +1,41 @@
+#!/usr/bin/perl
+# This program uses the po plugin's internals to convert the po files that
+# it generates back into translated wiki source files that can be used as a
+# underlay for a non-English wiki.
+use warnings;
+use strict;
+use IkiWiki;
+
+# Load the passed setup file and initialize ikiwiki config.
+%config=IkiWiki::defaultconfig();
+require IkiWiki::Setup;
+IkiWiki::Setup::load(shift);
+IkiWiki::loadplugins();
+IkiWiki::checkconfig();
+
+require IkiWiki::Render;
+IkiWiki::srcdir_check();
+my ($files, $pages)=IkiWiki::find_src_files();
+
+foreach my $file (@$files) {
+ my $page=pagename($file);
+ $pagesources{$page}=$file; # used by po plugin functions
+}
+
+foreach my $ll (keys %{$config{po_slave_languages}}) {
+ $config{destdir}="../underlays/locale/$ll";
+
+ foreach my $file (@$files) {
+ my $page=pagename($file);
+ my ($masterpage, $lang) = IkiWiki::Plugin::po::_istranslation($page);
+ next unless defined $lang && $lang eq $ll;
+
+ my $content=IkiWiki::Plugin::po::po_to_markup($page, readfile(srcfile($file)));
+ # avoid wasting space if the page is not translated at all
+ my $mastercontent=readfile(srcfile($pagesources{$masterpage}));
+ if ($content ne $mastercontent) {
+ writefile($masterpage.".".$config{default_pageext},
+ $config{destdir}, $content);
+ }
+ }
+}