return
plugin => {
safe => 0,
- rebuild => 1,
+ rebuild => 1, # format plugin
+ section => "format",
},
po_master_language => {
type => "string",
$field, 'po'));
}
}
+ delete $config{po_slave_languages}{$config{po_master_language}{code}};;
map {
islanguagecode($_)
if ($config{po_master_language}{code} ne 'en') {
# Add underlay containing translated source files
# for the master language.
- add_underlay("locale/$config{po_master_language}{code}/$underlay");
+ add_underlay("locale/$config{po_master_language}{code}/$underlay")
+ if -d "$config{underlaydirbase}/locale/$config{po_master_language}{code}/$underlay";
}
}
}
if (ishomepage($page) && $template->query(name => "title")) {
$template->param(title => $config{wikiname});
}
-} # }}}
+}
# Add the renamed page translations to the list of to-be-renamed pages.
sub renamepages (@) {
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 $link=shift;
return $origsubs{'bestlink'}->($page, $link)
- if $config{po_link_to} eq "default";
+ if defined $config{po_link_to} && $config{po_link_to} eq "default";
my $res=$origsubs{'bestlink'}->(masterpage($page), $link);
my @caller = caller(1);
my $url=shift;
my $res=$origsubs{'beautify_urlpath'}->($url);
- if ($config{po_link_to} eq "negotiated") {
+ if (defined $config{po_link_to} && $config{po_link_to} eq "negotiated") {
$res =~ s!/\Qindex.$config{po_master_language}{code}.$config{htmlext}\E$!/!;
$res =~ s!/\Qindex.$config{htmlext}\E$!/!;
map {
my $type=pagetype($file);
return 0 if ! defined $type || $type eq 'po';
return 0 if $file =~ /\.pot$/;
+ return 0 if ! defined $config{po_translatable_pages};
return 1 if pagespec_match(pagename($file), $config{po_translatable_pages});
return;
}
IkiWiki::saveindex();
}
-# on success, returns the filtered content.
-# on error, if $nonfatal, warn and return undef; else, error out.
-sub po_to_markup ($$;$) {
+sub po_to_markup ($$) {
my ($page, $content) = (shift, shift);
- my $nonfatal = shift;
$content = '' unless defined $content;
$content = decode_utf8(encode_utf8($content));
my $fail = sub ($) {
my $msg = "po(po_to_markup) - $page : " . shift;
- if ($nonfatal) {
- warn $msg;
- return undef;
- }
error($msg, sub { unlink $infile, $outfile});
};
$doc->write($outfile)
or return $fail->(sprintf(gettext("failed to write %s"), $outfile));
- $content = readfile($outfile)
- or return $fail->(sprintf(gettext("failed to read %s"), $outfile));
+ $content = readfile($outfile);
# Unlinking should happen automatically, thanks to File::Temp,
# but it does not work here, probably because of the way writefile()