- foreach my $file (@$needsbuild) {
- my $page=pagename($file);
- refreshpot(srcfile($file)) if (istranslatable($page));
- my @pofiles;
- foreach my $lang (keys %{$translations{$page}}) {
- push @pofiles, $pagesources{$translations{$page}{$lang}};
+ # refresh/create POT and PO files as needed
+ my $updated_po_files=0;
+ foreach my $page (keys %pagesources) {
+ my $pageneedsbuild = grep { $_ eq $pagesources{$page} } @$needsbuild;
+ if (istranslatable($page)) {
+ my $file=srcfile($pagesources{$page});
+ if ($pageneedsbuild || ! -e potfile($file)) {
+ refreshpot($file);
+ }
+ my @pofiles;
+ foreach my $lang (keys %{$config{po_slave_languages}}) {
+ my $pofile=pofile($file, $lang);
+ if ($pageneedsbuild || ! -e $pofile) {
+ push @pofiles, $pofile;
+ }
+ }
+ if (@pofiles) {
+ refreshpofiles($file, @pofiles) ;
+ map { IkiWiki::rcs_add($_); } @pofiles if ($config{rcs});
+ $updated_po_files = 1;
+ }
+ }
+ }
+
+ # check staged changes in and trigger a wiki refresh.
+ if ($updated_po_files) {
+ if ($config{rcs}) {
+ IkiWiki::disable_commit_hook();
+ IkiWiki::rcs_commit_staged(gettext("updated PO files"),
+ "refreshpofiles", "127.0.0.1");
+ IkiWiki::enable_commit_hook();
+ IkiWiki::rcs_update();
+ }
+ IkiWiki::refresh();
+ IkiWiki::saveindex();
+ # refresh module's private variables
+ %filtered=undef;
+ %translations=undef;
+ foreach my $page (keys %pagesources) {
+ istranslation($page);
+ }
+ }
+
+
+ # make existing translations depend on the corresponding master page
+ foreach my $master (keys %translations) {
+ foreach my $slave (values %{$translations{$master}}) {
+ add_depends($slave, $master);