po: delete translations of deleted master pages
Signed-off-by: intrigeri <intrigeri@boum.org>master
parent
cd62acfb47
commit
bd10381103
|
@ -389,26 +389,9 @@ sub change(@) { #{{{
|
|||
}
|
||||
|
||||
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.
|
||||
resetalreadyfiltered();
|
||||
resettranslationscache();
|
||||
flushmemoizecache();
|
||||
# Trigger a wiki refresh.
|
||||
require IkiWiki::Render;
|
||||
# without preliminary saveindex/loadindex, refresh()
|
||||
# complains about a lot of uninitialized variables
|
||||
IkiWiki::saveindex();
|
||||
IkiWiki::loadindex();
|
||||
IkiWiki::refresh();
|
||||
IkiWiki::saveindex();
|
||||
commit_and_refresh(
|
||||
gettext("updated PO files"),
|
||||
"IkiWiki::Plugin::po::change");
|
||||
}
|
||||
} #}}}
|
||||
|
||||
|
@ -792,7 +775,53 @@ sub homepageurl (;$) { #{{{
|
|||
sub deletetranslations ($) { #{{{
|
||||
my $deletedmasterfile=shift;
|
||||
|
||||
debug "po(deletetranslations): TODO: delete translations of $deletedmasterfile";
|
||||
my $deletedmasterpage=pagename($deletedmasterfile);
|
||||
my @todelete;
|
||||
map {
|
||||
my $file = newpagefile($deletedmasterpage.'.'.$_, 'po');
|
||||
my $absfile = "$config{srcdir}/$file";
|
||||
if (-e $absfile && ! -l $absfile && ! -d $absfile) {
|
||||
push @todelete, $file;
|
||||
}
|
||||
} keys %{$config{po_slave_languages}};
|
||||
|
||||
map {
|
||||
if ($config{rcs}) {
|
||||
IkiWiki::rcs_remove($_);
|
||||
}
|
||||
else {
|
||||
IkiWiki::prune("$config{srcdir}/$_");
|
||||
}
|
||||
} @todelete;
|
||||
|
||||
if (scalar @todelete) {
|
||||
commit_and_refresh(
|
||||
gettext("removed obsolete PO files"),
|
||||
"IkiWiki::Plugin::po::deletetranslations");
|
||||
}
|
||||
} #}}}
|
||||
|
||||
sub commit_and_refresh ($$) { #{{{
|
||||
my ($msg, $author) = (shift, shift);
|
||||
|
||||
if ($config{rcs}) {
|
||||
IkiWiki::disable_commit_hook();
|
||||
IkiWiki::rcs_commit_staged($msg, $author, "127.0.0.1");
|
||||
IkiWiki::enable_commit_hook();
|
||||
IkiWiki::rcs_update();
|
||||
}
|
||||
# Reinitialize module's private variables.
|
||||
resetalreadyfiltered();
|
||||
resettranslationscache();
|
||||
flushmemoizecache();
|
||||
# Trigger a wiki refresh.
|
||||
require IkiWiki::Render;
|
||||
# without preliminary saveindex/loadindex, refresh()
|
||||
# complains about a lot of uninitialized variables
|
||||
IkiWiki::saveindex();
|
||||
IkiWiki::loadindex();
|
||||
IkiWiki::refresh();
|
||||
IkiWiki::saveindex();
|
||||
} #}}}
|
||||
|
||||
# ,----
|
||||
|
|
|
@ -562,11 +562,9 @@ Creating new pages on the web
|
|||
|
||||
See [[contrib/po|contrib/po]].
|
||||
|
||||
Deleting/renaming pages
|
||||
-----------------------
|
||||
Renaming pages
|
||||
--------------
|
||||
|
||||
- When a master page is renamed or deleted, its translations (and the
|
||||
pot file?) must be renamed or deleted accordingly.
|
||||
- Renaming a translation should be forbidden.
|
||||
|
||||
Robustness tests
|
||||
|
@ -596,16 +594,17 @@ Robustness tests
|
|||
|
||||
### Deleting pages
|
||||
|
||||
- removing a master page via RCS
|
||||
- removing a master page via RCS: **OK**
|
||||
- removing a translation via RCS: **OK**
|
||||
- removing a master page via CGI
|
||||
- removing a master page via CGI: **OK**
|
||||
- removing a translation via CGI: **OK**
|
||||
|
||||
### Renaming pages
|
||||
|
||||
- renaming a master page via RCS
|
||||
- renaming a master page and its translations via RCS
|
||||
- renaming a master page via CGI
|
||||
- renaming a master page via RCS: **OK** (but the old translations
|
||||
are lost, because not all RCS track file renaming)
|
||||
- renaming a master page and its translations via RCS: **OK**
|
||||
- renaming a master page via CGI: **OK**
|
||||
- renaming a translation via RCS
|
||||
- renaming a translation via CGI
|
||||
|
||||
|
|
Loading…
Reference in New Issue