hook(type => "formbuilder_setup", id => "po", call => \&formbuilder_setup, last => 1);
hook(type => "formbuilder", id => "po", call => \&formbuilder);
+ $origsubs{'bestlink'}=\&IkiWiki::bestlink;
+ inject(name => "IkiWiki::bestlink", call => \&mybestlink);
$origsubs{'beautify_urlpath'}=\&IkiWiki::beautify_urlpath;
inject(name => "IkiWiki::beautify_urlpath", call => \&mybeautify_urlpath);
$origsubs{'targetpage'}=\&IkiWiki::targetpage;
warn(gettext('po_link_to=negotiated requires usedirs to be enabled, falling back to po_link_to=default'));
$config{po_link_to}='default';
}
- unless ($config{po_link_to} eq 'default') {
- $origsubs{'bestlink'}=\&IkiWiki::bestlink;
- inject(name => "IkiWiki::bestlink", call => \&mybestlink);
- }
push @{$config{wiki_file_prune_regexps}}, qr/\.pot$/;
resetalreadyfiltered();
require IkiWiki::Render;
foreach my $file (@rendered) {
- debug(sprintf(gettext("building %s"), $file));
- IkiWiki::render($file);
+ IkiWiki::render($file, sprintf(gettext("building %s"), $file));
}
}
my $updated_po_files=0;
# Refresh/create POT and PO files as needed.
- # (But avoid doing so if they are in an underlay directory.)
foreach my $file (grep {istranslatablefile($_)} @rendered) {
my $masterfile=srcfile($file);
my $page=pagename($file);
my $updated_pot_file=0;
+
+ # Avoid touching underlay files.
+ next if $masterfile ne "$config{srcdir}/$file";
+
# Only refresh POT file if it does not exist, or if
- # $pagesources{$page} was changed: don't if only the HTML was
+ # the source was changed: don't if only the HTML was
# refreshed, e.g. because of a dependency.
- if ($masterfile eq "$config{srcdir}/$file" &&
- ((grep { $_ eq $pagesources{$page} } @origneedsbuild)
- || ! -e potfile($masterfile))) {
+ if ((grep { $_ eq $pagesources{$page} } @origneedsbuild) ||
+ ! -e potfile($masterfile)) {
refreshpot($masterfile);
$updated_pot_file=1;
}
my @pofiles;
foreach my $po (pofiles($masterfile)) {
- next if ! $updated_pot_file && ! -e $po;
+ next if ! $updated_pot_file && -e $po;
next if grep { $po=~/\Q$_\E/ } @{$config{underlaydirs}};
push @pofiles, $po;
}
# `----
# Implement po_link_to 'current' and 'negotiated' settings.
-# Not injected otherwise.
sub mybestlink ($$) {
my $page=shift;
my $link=shift;
+ return $origsubs{'bestlink'}->($page, $link)
+ if $config{po_link_to} eq "default";
+
my $res=$origsubs{'bestlink'}->(masterpage($page), $link);
+ my @caller = caller(1);
if (length $res
&& istranslatable($res)
- && istranslation($page)) {
+ && istranslation($page)
+ && !(exists $caller[3] && defined $caller[3]
+ && ($caller[3] eq "IkiWiki::PageSpec::match_link"))) {
return $res . "." . lang($page);
}
return $res;