diff options
author | Joey Hess <joey@gnu.kitenet.net> | 2009-07-20 06:23:33 +0200 |
---|---|---|
committer | Joey Hess <joey@gnu.kitenet.net> | 2009-07-20 06:23:33 +0200 |
commit | 741c33576e358d555e623a49d42edd33924a19ab (patch) | |
tree | 2ea03c9986c45644fe40d5af166c4bd37564f8e9 /po/po2wiki | |
parent | 73ae87a4d475e4702e7135adef0a5be4b0c54279 (diff) | |
download | ikiwiki-741c33576e358d555e623a49d42edd33924a19ab.tar ikiwiki-741c33576e358d555e623a49d42edd33924a19ab.tar.gz |
create translated underlays in mdwn format
These are for use by wikis where the primary language is not English.
On such a wiki, it makes sense to use an underlay has the source for pages
in the native language.
Diffstat (limited to 'po/po2wiki')
-rwxr-xr-x | po/po2wiki | 37 |
1 files changed, 37 insertions, 0 deletions
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); + } +} |