comment: Better fix to avoid showing comments of subpages, while not breaking manual...
[ikiwiki.git] / po / po2wiki
blob126aa8e17d0949d0c9a55477268464936092ff33
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;
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();
16 require IkiWiki::Render;
17 IkiWiki::srcdir_check();
18 my ($files, $pages)=IkiWiki::find_src_files();
20 foreach my $file (@$files) {
21 my $page=pagename($file);
22 $pagesources{$page}=$file; # used by po plugin functions
25 foreach my $lang (@{$config{po_slave_languages}}) {
26 my ($ll, $name)=IkiWiki::Plugin::po::splitlangpair($lang);
27 $config{destdir}="../underlays/locale/$ll";
29 foreach my $file (@$files) {
30 my $page=pagename($file);
31 my ($masterpage, $lang) = IkiWiki::Plugin::po::_istranslation($page);
32 next unless defined $lang && $lang eq $ll;
34 my $content=IkiWiki::Plugin::po::po_to_markup($page, readfile(srcfile($file)));
35 # avoid wasting space if the page is not translated at all
36 my $mastercontent=readfile(srcfile($pagesources{$masterpage}));
37 if ($content ne $mastercontent) {
38 writefile($masterpage.".".$config{default_pageext},
39 $config{destdir}, $content);