[Po4a-commits] "po4a po4a,1.95,1.96 po4a-translate,1.42,1.43"
Denis Barbier
barbier-guest at alioth.debian.org
Wed Jan 20 23:17:02 UTC 2010
Update of /cvsroot/po4a/po4a
In directory alioth:/tmp/cvs-serv25030
Modified Files:
po4a po4a-translate
Log Message:
* po4a, po4a-translate: Improve handling of addenda as proposed on po4a-devel list
Index: po4a-translate
===================================================================
RCS file: /cvsroot/po4a/po4a/po4a-translate,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- po4a-translate 27 Dec 2009 01:16:01 -0000 1.42
+++ po4a-translate 20 Jan 2010 23:17:00 -0000 1.43
@@ -245,7 +245,37 @@
$master_filename, $percent, $threshold);
unlink($outfile) if (-e $outfile);
} else {
- foreach my $add (@addfiles) {
+ my %discarded = ();
+ my @files = ();
+ while (@addfiles) {
+ my $add = shift(@addfiles);
+ my $modifiers;
+ $add =~ s/^([@!?]+)// and $modifiers = $1;
+ next if defined($discarded{$add});
+ if (defined $modifiers) {
+ if ($modifiers =~ m/!/) {
+ $discarded{$add} = 1;
+ next;
+ }
+ next if ($modifiers =~ m/\?/ and not -e $add);
+ if ($modifiers =~ m/@/) {
+ open LIST,"<","$add" or die wrap_msg(gettext("Can't open %s: %s"), $add, $!);
+ my @new_list = ();
+ while(<LIST>) {
+ chomp;
+ next if length($_) == 0 or $_ =~ m/^\s*#/;
+ push(@new_list, $_);
+ }
+ close LIST;
+ unshift(@addfiles, @new_list);
+ } else {
+ push @files,$add;
+ }
+ } else {
+ push @files,$add;
+ }
+ }
+ for my $add (@files) {
unless ($doc->addendum($add)) {
unlink($outfile) if (-e $outfile);
die wrap_msg(gettext("Discard the translation of %s (addendum %s does not apply)."),
Index: po4a
===================================================================
RCS file: /cvsroot/po4a/po4a/po4a,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -d -r1.95 -r1.96
--- po4a 20 Jan 2010 20:37:10 -0000 1.95
+++ po4a 20 Jan 2010 23:17:00 -0000 1.96
@@ -837,7 +837,12 @@
}
%{$document{$main}{'options'}} = %options;
- foreach my $arg (split(/ /,$args)) {
+ chdir $po4a_opts{"srcdir"}
+ if (defined $po4a_opts{"srcdir"});
+ my %discarded = ();
+ my @remaining_args = split(/ /,$args);
+ while (@remaining_args) {
+ my $arg = shift(@remaining_args);
die wrap_ref_mod("$config_file:$nb", "",
gettext("Unparsable argument '%s' (%s)."), $arg, $line)
unless ($arg =~ /^([^:]*):(.*)/);
@@ -847,7 +852,31 @@
if ($main eq $trans);
if ($lang =~ /^add_/) {
- push @{$document{$main}{$lang}},$trans;
+ my $modifiers;
+ $trans =~ s/^([@!?]+)// and $modifiers = $1;
+ next if defined($discarded{$trans});
+ if (defined $modifiers) {
+ if ($modifiers =~ m/!/) {
+ $discarded{$trans} = 1;
+ next;
+ }
+ next if ($modifiers =~ m/\?/ and not -e $trans);
+ if ($modifiers =~ m/@/) {
+ open LIST,"<","$trans" or die wrap_msg(gettext("Can't open %s: %s"), $trans, $!);
+ my @new_list = ();
+ while(<LIST>) {
+ chomp;
+ next if length($_) == 0 or $_ =~ m/^\s*#/;
+ push(@new_list, "$lang:$_");
+ }
+ close LIST;
+ unshift(@remaining_args, @new_list);
+ } else {
+ push @{$document{$main}{$lang}},$trans;
+ }
+ } else {
+ push @{$document{$main}{$lang}},$trans;
+ }
} else {
die wrap_ref_mod("$config_file:$nb", "",
gettext("Translation of %s in %s redefined"), $main, $lang)
@@ -855,6 +884,8 @@
$document{$main}{$lang} = $trans;
}
}
+ chdir $po4a_opts{"calldir"}
+ if (defined $po4a_opts{"srcdir"});
} elsif ($cmd =~ m/po4a_alias: *(.*)/) {
my $name = $1;
my %alias = ();
More information about the Po4a-commits
mailing list