+sub change(@) { #{{{
+ my @rendered=@_;
+
+ my $updated_po_files=0;
+
+ # Refresh/create POT and PO files as needed.
+ foreach my $page (map pagename($_), @rendered) {
+ next unless istranslatable($page);
+ my $file=srcfile($pagesources{$page});
+ my $updated_pot_file=0;
+ if ((grep { $_ eq $pagesources{$page} } @origneedsbuild)
+ || ! -e potfile($file)) {
+ refreshpot($file);
+ $updated_pot_file=1;
+ }
+ my @pofiles;
+ foreach my $lang (keys %{$config{po_slave_languages}}) {
+ my $pofile=pofile($file, $lang);
+ if ($updated_pot_file || ! -e $pofile) {
+ push @pofiles, $pofile;
+ }
+ }
+ if (@pofiles) {
+ refreshpofiles($file, @pofiles);
+ map { IkiWiki::rcs_add($_); } @pofiles if ($config{rcs});
+ $updated_po_files=1;
+ }
+ }
+
+ if ($updated_po_files) {
+ # Check staged changes in.
+ if ($config{rcs}) {
+ IkiWiki::disable_commit_hook();
+ IkiWiki::rcs_commit_staged(gettext("updated PO files"),
+ "IkiWiki::Plugin::po::change", "127.0.0.1");
+ IkiWiki::enable_commit_hook();
+ IkiWiki::rcs_update();
+ }
+ # Reinitialize module's private variables.
+ undef %filtered;
+ undef %translations;
+ # Trigger a wiki refresh.
+ require IkiWiki::Render;
+ IkiWiki::refresh();
+ IkiWiki::saveindex();
+ }
+} #}}}
+
+sub editcontent () { #{{{
+ my %params=@_;
+ # as we're previewing or saving a page, the content may have
+ # changed, so tell the next filter() invocation it must not be lazy
+ if (exists $filtered{$params{page}}{$params{page}}) {
+ delete $filtered{$params{page}}{$params{page}};
+ }
+ return $params{content};
+} #}}}
+