summaryrefslogtreecommitdiff
path: root/po/po2wiki
blob: 031c906cb766cb3107caa94908adfeb1ef883097 (plain)
  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. # Load the passed setup file and initialize ikiwiki config.
  9. %config=IkiWiki::defaultconfig();
  10. require IkiWiki::Setup;
  11. IkiWiki::Setup::load(shift);
  12. IkiWiki::loadplugins();
  13. IkiWiki::checkconfig();
  14. require IkiWiki::Render;
  15. IkiWiki::srcdir_check();
  16. my ($files, $pages)=IkiWiki::find_src_files();
  17. foreach my $file (@$files) {
  18. my $page=pagename($file);
  19. $pagesources{$page}=$file; # used by po plugin functions
  20. }
  21. foreach my $ll (keys %{$config{po_slave_languages}}) {
  22. $config{destdir}="po/out.$ll";
  23. foreach my $file (@$files) {
  24. my $page=pagename($file);
  25. my ($masterpage, $lang) = IkiWiki::Plugin::po::_istranslation($page);
  26. next unless defined $lang && $lang eq $ll;
  27. my $content=readfile(srcfile($file));
  28. $content=IkiWiki::Plugin::po::po_to_markup($page, $content);
  29. writefile($masterpage.".".$config{default_pageext}, $config{destdir}, $content);
  30. }
  31. }