summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IkiWiki/Plugin/po.pm8
-rwxr-xr-xMakefile.PL1
-rw-r--r--doc/plugins/po.mdwn3
-rwxr-xr-xpo/po2wiki37
4 files changed, 45 insertions, 4 deletions
diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm
index 1aa60a14f..2939bcd9a 100644
--- a/IkiWiki/Plugin/po.pm
+++ b/IkiWiki/Plugin/po.pm
@@ -904,10 +904,10 @@ sub otherlanguagesloop ($) {
}
}
return sort {
- return -1 if $a->{code} eq $config{po_master_language}{code};
- return 1 if $b->{code} eq $config{po_master_language}{code};
- return $a->{language} cmp $b->{language};
- } @ret;
+ return -1 if $a->{code} eq $config{po_master_language}{code};
+ return 1 if $b->{code} eq $config{po_master_language}{code};
+ return $a->{language} cmp $b->{language};
+ } @ret;
}
sub homepageurl (;$) {
diff --git a/Makefile.PL b/Makefile.PL
index 3db5c0d40..397627c03 100755
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -64,6 +64,7 @@ underlaypo: ikiwiki.out
done
install -d po/underlays/empty
$(PERL) -Iblib/lib $(extramodules) $(tflag) ikiwiki.out -libdir . -setup underlaypo.setup -refresh
+ PERL5LIB=. po/po2wiki underlaypo.setup
find po/underlays -name \*.mdwn | xargs rm -f
extra_clean:
diff --git a/doc/plugins/po.mdwn b/doc/plugins/po.mdwn
index f28c8b188..8e05606f5 100644
--- a/doc/plugins/po.mdwn
+++ b/doc/plugins/po.mdwn
@@ -286,6 +286,9 @@ The when the user edits index, they get a nice mdwn file to start from.
So, we seem to have two cases, in one po files from the underlay should be
used, in the other not. Hmm. Support both?
+
+> Update -- I've written po2wiki, which can spit out translated underlays
+> in markdown format.
--[[Joey]]
Duplicate %links ?
diff --git a/po/po2wiki b/po/po2wiki
new file mode 100755
index 000000000..031c906cb
--- /dev/null
+++ b/po/po2wiki
@@ -0,0 +1,37 @@
+#!/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}="po/out.$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=readfile(srcfile($file));
+ $content=IkiWiki::Plugin::po::po_to_markup($page, $content);
+ writefile($masterpage.".".$config{default_pageext}, $config{destdir}, $content);
+ }
+}