]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/po.pm
po(delete): added hook, and function skeleton
[ikiwiki.git] / IkiWiki / Plugin / po.pm
index f13093963d33e50f2bc3d597646eca1fd665d418..60a9f26322cdb34dae9f71e1148eb47f158ee7a0 100644 (file)
@@ -35,6 +35,7 @@ sub import { #{{{
        hook(type => "filter", id => "po", call => \&filter);
        hook(type => "htmlize", id => "po", call => \&htmlize);
        hook(type => "pagetemplate", id => "po", call => \&pagetemplate, last => 1);
+       hook(type => "delete", id => "po", call => \&mydelete);
        hook(type => "change", id => "po", call => \&change);
        hook(type => "editcontent", id => "po", call => \&editcontent);
 
@@ -325,30 +326,37 @@ sub pagetemplate (@) { #{{{
        }
 } # }}}
 
+sub mydelete(@) { #{{{
+       my @deleted=@_;
+
+       map { deletetranslations($_) } grep istranslatablefile($_), @deleted;
+} #}}}
+
 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});
+       foreach my $file (@rendered) {
+               next unless istranslatablefile($file);
+               my $page=pagename($file);
+               my $masterfile=srcfile($file);
                my $updated_pot_file=0;
                # Only refresh Pot file if it does not exist, or if
                # $pagesources{$page} was changed: don't if only the HTML was
                # refreshed, e.g. because of a dependency.
                if ((grep { $_ eq $pagesources{$page} } @origneedsbuild)
-                   || ! -e potfile($file)) {
-                       refreshpot($file);
+                   || ! -e potfile($masterfile)) {
+                       refreshpot($masterfile);
                        $updated_pot_file=1;
                }
                my @pofiles;
                map {
                        push @pofiles, $_ if ($updated_pot_file || ! -e $_);
-               } (pofiles($file));
+               } (pofiles($masterfile));
                if (@pofiles) {
-                       refreshpofiles($file, @pofiles);
+                       refreshpofiles($masterfile, @pofiles);
                        map { IkiWiki::rcs_add($_); } @pofiles if ($config{rcs});
                        $updated_po_files=1;
                }
@@ -756,6 +764,13 @@ sub homepageurl (;$) { #{{{
        return urlto('', $page);
 } #}}}
 
+# do *not* implement this until the renamepage hook works
+sub deletetranslations ($) { #{{{
+       my $file=shift;
+
+       debug 'po(deletetranslations): TODO: delete translations of ' . $file;
+} #}}}
+
 # ,----
 # | PageSpec's
 # `----