]> sipb.mit.edu Git - ikiwiki.git/blob - po/po2wiki
create translated underlays in mdwn format
[ikiwiki.git] / po / po2wiki
1 #!/usr/bin/perl
2 # This program uses the po plugin's internals to convert the po files that
3 # it generates back into translated wiki source files that can be used as a
4 # underlay for a non-English wiki.
5 use warnings;
6 use strict;
7 use IkiWiki;
8
9 # Load the passed setup file and initialize ikiwiki config.
10 %config=IkiWiki::defaultconfig();
11 require IkiWiki::Setup;
12 IkiWiki::Setup::load(shift);
13 IkiWiki::loadplugins();
14 IkiWiki::checkconfig();
15
16 require IkiWiki::Render;
17 IkiWiki::srcdir_check();
18 my ($files, $pages)=IkiWiki::find_src_files();
19
20 foreach my $file (@$files) {
21         my $page=pagename($file);
22         $pagesources{$page}=$file; # used by po plugin functions
23 }
24
25 foreach my $ll (keys %{$config{po_slave_languages}}) {
26         $config{destdir}="po/out.$ll";
27
28         foreach my $file (@$files) {
29                 my $page=pagename($file);
30                 my ($masterpage, $lang) = IkiWiki::Plugin::po::_istranslation($page);
31                 next unless defined $lang && $lang eq $ll;
32                 
33                 my $content=readfile(srcfile($file));
34                 $content=IkiWiki::Plugin::po::po_to_markup($page, $content);
35                 writefile($masterpage.".".$config{default_pageext}, $config{destdir}, $content);
36         }
37 }