X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/741c33576e358d555e623a49d42edd33924a19ab..766311f45b4351488d7dad519a6471094a58da16:/po/po2wiki?ds=inline

diff --git a/po/po2wiki b/po/po2wiki
index 031c906cb..862aa9d97 100755
--- a/po/po2wiki
+++ b/po/po2wiki
@@ -22,16 +22,23 @@ foreach my $file (@$files) {
 	$pagesources{$page}=$file; # used by po plugin functions
 }
 
-foreach my $ll (keys %{$config{po_slave_languages}}) {
-	$config{destdir}="po/out.$ll";
+$IkiWiki::phase = IkiWiki::PHASE_RENDER;
+
+foreach my $lang (@{$config{po_slave_languages}}) {
+	my ($ll, $name)=IkiWiki::Plugin::po::splitlangpair($lang);
+	$config{destdir}="../underlays/locale/$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);
+		my $content=IkiWiki::Plugin::po::po_to_markup($page, readfile(srcfile($file)));
+		# avoid wasting space if the page is not translated at all
+		my $mastercontent=readfile(srcfile($pagesources{$masterpage}));
+		if ($content ne $mastercontent) {
+			writefile($masterpage.".".$config{default_pageext},
+				$config{destdir}, $content);
+		}
 	}
 }