my %translations;
my @origneedsbuild;
my %origsubs;
-my @slavelanguages; # orderer as in config po_slave_languages
+my @slavelanguages; # languages codes ordered as in config po_slave_languages
memoize("istranslatable");
memoize("_istranslation");
po_slave_languages => {
type => "string",
example => [
- 'fr' => 'Français',
- 'es' => 'Español',
- 'de' => 'Deutsch'
- ],
+ 'fr|Français',
+ 'es|Español',
+ 'de|Deutsch'
+ ],
description => "slave languages (PO files)",
safe => 1,
rebuild => 1,
if (ref $config{po_slave_languages} eq 'ARRAY') {
my %slaves;
- for (my $i=0; $i<@{$config{po_slave_languages}}; $i = $i + 2) {
- $slaves{$config{po_slave_languages}->[$i]} = $config{po_slave_languages}->[$i + 1];
- push @slavelanguages, $config{po_slave_languages}->[$i];
+ foreach my $pair (@{$config{po_slave_languages}}) {
+ my ($code, $name) = ( $pair =~ /^([a-z]{2})\|(.+)$/ );
+ if (!defined $code || !defined $name) {
+ error(sprintf(gettext("%s has invalid syntax: must use CODE|NAME"),
+ $pair));
+ }
+ $slaves{$code} = $name;
+ push @slavelanguages, $code;
+
}
$config{po_slave_languages} = \%slaves;
}
my $page = $params{page};
my $destpage = $params{destpage};
my $content = $params{content};
- my $fullpage = $params{fullpage};
-
- unless ($fullpage) {
- return $content;
- }
-
if (istranslation($page) && ! alreadyfiltered($page, $destpage)) {
$content = po_to_markup($page, $content);
setalreadyfiltered($page, $destpage);
return \@ret unless istranslation($page) || istranslatable($page);
my $curlang=lang($page);
foreach my $lang
- ($config{po_master_language}{code}, @slavelanguages) {
+ ($config{po_master_language}{code}, keys %{$config{po_slave_languages}}) {
next if $lang eq $curlang;
push @ret, $lang;
}
sub match_needstranslation ($$;@) {
my $page=shift;
+ my $wanted=shift;
+
+ if (defined $wanted && $wanted ne "") {
+ if ($wanted !~ /^\d+$/) {
+ return IkiWiki::FailReason->new("parameter is not an integer");
+ }
+ elsif ($wanted > 100) {
+ return IkiWiki::FailReason->new("parameter is greater than 100");
+ }
+ }
+ else {
+ $wanted=100;
+ }
my $percenttranslated=IkiWiki::Plugin::po::percenttranslated($page);
if ($percenttranslated eq 'N/A') {
- return IkiWiki::FailReason->new("file is not a translation page");
+ return IkiWiki::FailReason->new("file is not a translatable page");
}
- elsif ($percenttranslated < 100) {
+ elsif ($percenttranslated < $wanted) {
return IkiWiki::SuccessReason->new("file has $percenttranslated translated");
}
else {
- return IkiWiki::FailReason->new("file is fully translated");
+ return IkiWiki::FailReason->new("file is translated enough");
}
}