[Po4a-devel][CVS] po4a po4a-translate,1.23,1.24
by Martin Quinson
Update of /cvsroot/po4a/po4a
In directory haydn:/tmp/cvs-serv17297
Modified Files:
po4a-translate
Log Message:
Message polishing
Index: po4a-translate
===================================================================
RCS file: /cvsroot/po4a/po4a/po4a-translate,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- po4a-translate 18 Jul 2004 05:13:24 -0000 1.23
+++ po4a-translate 18 Jul 2004 08:47:22 -0000 1.24
@@ -231,7 +231,7 @@
my ($percent,$hit,$queries) = $doc->stats();
my $error=0;
-print STDERR sprintf(gettext("%s is %s%% translated (%s of %s strings)"),
+print STDERR sprintf(gettext("%s is %s%% translated (%s of %s strings)."),
$master_filename,$percent,$hit,$queries)."\n"
if $verbose && ($percent>=$threshold);
20 years, 5 months
[Po4a-devel][CVS] po4a po4a,1.9,1.10
by Martin Quinson
Update of /cvsroot/po4a/po4a
In directory haydn:/tmp/cvs-serv32361
Modified Files:
po4a
Log Message:
Add '\n' where needed
Index: po4a
===================================================================
RCS file: /cvsroot/po4a/po4a/po4a,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- po4a 18 Jul 2004 08:33:36 -0000 1.9
+++ po4a 18 Jul 2004 08:42:53 -0000 1.10
@@ -269,7 +269,7 @@
unless ($arg =~ /^([^:]*):(.*)/);
my ($lang,$trans)=($1,$2);
die sprintf("%s:%d: ".
- gettext("The translated and master file are the same."),
+ gettext("The translated and master file are the same.")."\n",
$config_file,$nb)
if ($main eq $trans);
20 years, 5 months
[Po4a-devel][CVS] po4a/lib/Locale/Po4a TransTractor.pm,1.24,1.25
by Martin Quinson
Update of /cvsroot/po4a/po4a/lib/Locale/Po4a
In directory haydn:/tmp/cvs-serv31704/lib/Locale/Po4a
Modified Files:
TransTractor.pm
Log Message:
Addendum: More robust to user error; message polishing
Index: TransTractor.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/TransTractor.pm,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- TransTractor.pm 18 Jul 2004 06:10:24 -0000 1.24
+++ TransTractor.pm 18 Jul 2004 08:35:05 -0000 1.25
@@ -533,9 +533,11 @@
unless ($filename) {
warn(dgettext("po4a",
- "Can't insert addendum when not given the filename")."\n");
+ "Can't apply addendum when not given the filename")."\n");
return 0;
}
+ die sprintf(dgettext("po4a","Addendum %s does not exist.")."\n",$filename)
+ unless -e $filename;
my ($errcode,$mode,$position,$boundary,$bmode,$lang,$content)=
addendum_parse($filename);
@@ -556,8 +558,8 @@
}
if ($mode eq "before") {
- if ($self->verbose() > 0) {
- map { print STDERR sprintf(dgettext("po4a","Adding the addendum %s before the line:\n%s"),
+ if ($self->verbose() > 1) {
+ map { print STDERR sprintf(dgettext("po4a","Addendum '%s' applied before this line: %s"),
$filename,$_)."\n" if (/$position/);
} @{$self->{TT}{doc_out}};
}
@@ -567,35 +569,34 @@
my @newres=();
while (my $line=shift @{$self->{TT}{doc_out}}) {
push @newres,$line;
+ my $outline=mychomp($line);
+ $outline =~ s/^[ \t]*//;
+
if ($line =~ m/$position/) {
- print STDERR sprintf(dgettext("po4a",
- "Adding the addendum %s after the section begining with the line:\n%s"),
- $filename,mychomp($line))."\n" if ($self->verbose() > 0);
while ($line=shift @{$self->{TT}{doc_out}}) {
last if ($line=~/$boundary/);
push @newres,$line;
}
if (defined $line) {
if ($bmode eq 'before') {
- printf STDERR (dgettext("po4a",
- "Next section begins with:\n".
- "%s\n".
- "Addendum added before this line."),
- mychomp($line))."\n" if ($self->verbose() > 0);
+ print sprintf (dgettext("po4a",
+ "Addendum '%s' applied before this line: %s")."\n",
+ $filename,$outline)
+ if ($self->verbose() > 1);
push @newres,$content;
push @newres,$line;
} else {
- printf STDERR (dgettext("po4a",
- "This section ends with:\n".
- "%s\n".
- "Addendum added after this line."),
- mychomp($line))."\n" if ($self->verbose() > 0);
+ print sprintf (dgettext("po4a",
+ "Addendum '%s' applied after the line: %s.")."\n",
+ $filename,$outline)
+ if ($self->verbose() > 1);
push @newres,$line;
push @newres,$content;
}
} else {
- printf STDERR (dgettext("po4a","Can't find the end of the section in the file. Addendum added at the end of the file."))."\n"
- if ($self->verbose() > 0);
+ print sprintf (dgettext("po4a","Addendum '%s' applied at the end of the file.")."\n",
+ $filename)
+ if ($self->verbose() > 1);
push @newres,$content;
}
}
20 years, 5 months
[Po4a-devel][CVS] po4a po4a,1.8,1.9
by Martin Quinson
Update of /cvsroot/po4a/po4a
In directory haydn:/tmp/cvs-serv31654
Modified Files:
po4a
Log Message:
several -v=> more verbosity; let the addendum work; various bug fix and cleanup; invert the loop on document and lang, so that all doc of the same lang are together
Index: po4a
===================================================================
RCS file: /cvsroot/po4a/po4a/po4a,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- po4a 18 Jul 2004 07:15:16 -0000 1.8
+++ po4a 18 Jul 2004 08:33:36 -0000 1.9
@@ -178,14 +178,14 @@
exit 0;
}
-my ($help,$type,$debug,$verbose,$quiet,@options);
-$verbose = 0;
+my ($help,$type,$debug,@verbose,$quiet,@options);
+@verbose = ();
$debug = 0;
my ($threshold)=(80);
Getopt::Long::config('bundling', 'no_getopt_compat', 'no_auto_abbrev');
GetOptions(
'help|h' => \$help,
- 'verbose|v' => \$verbose,
+ 'verbose|v' => \@verbose,
'debug|d' => \$debug,
'quiet|q' => \$quiet,
'keep|k=s' => \$threshold,
@@ -195,6 +195,7 @@
# Argument check
$help && pod2usage (0);
+my ($verbose) = (scalar @verbose);
$verbose = 1 if $debug;
$verbose = -1 if $quiet;
my %options = (
@@ -223,12 +224,13 @@
$nb++;
s/#.*//;
$line.=$_;
- chomp($line);
- next if ($line =~ s/\\$//);
- next unless ($line =~ /\S/);
+ $line =~ s/\t/ /g;
$line =~ s/ +/ /g;
$line =~ s/^ //;
$line =~ s/ $//;
+ chomp($line);
+ next if ($line =~ s/\\$//);
+ next unless ($line =~ /\S/);
die sprintf("%s:%d: ".gettext("Syntax error: %s")."\n",$config_file,$nb,$line)
unless ($line =~ m/^\[([^\]]*)\] (\S+) (.*)$/ || $line =~ m/^\[([^\]]*)\] (\S+)$/);
@@ -250,7 +252,7 @@
$pot_filename = $main;
foreach my $arg (split(/ /,$args)) {
die sprintf("%s:%d: ".
- gettext("Unparsable argument '%s'").
+ gettext("Unparsable argument '%s'.").
"\n",
$config_file,$nb,$arg)
unless ($arg =~ /^([^:]*):(.*)/);
@@ -261,20 +263,30 @@
$document{$main}{'format'} = $1;
foreach my $arg (split(/ /,$args)) {
die sprintf("%s:%d: ".
- gettext("Unparsable argument '%s'").
+ gettext("Unparsable argument '%s' (%s).").
"\n",
- $config_file,$nb,$arg)
+ $config_file,$nb,$arg,$line)
unless ($arg =~ /^([^:]*):(.*)/);
+ my ($lang,$trans)=($1,$2);
die sprintf("%s:%d: ".
gettext("The translated and master file are the same."),
$config_file,$nb)
- if ($main eq $2);
- $document{$main}{$1} = $2;
+ if ($main eq $trans);
+
+ if ($lang =~ /add_/) {
+ push @{$document{$main}{$lang}},$trans;
+ } else {
+ die sprintf("%s:%d: ".
+ gettext("Translation of %s in %s redefined"),
+ $config_file,$nb,$main,$lang)
+ if (defined $document{$main}{$lang});
+ $document{$main}{$lang} = $trans;
+ }
}
} else {
die sprintf("%s:%d: ".
- gettext("Unparsable command '%s'")."\n",
+ gettext("Unparsable command '%s'.")."\n",
$config_file,$nb,$cmd);
}
@@ -311,8 +323,8 @@
if (-e $po_filename{$lang}) {
print STDERR sprintf(gettext("Updating %s: "),$po_filename{$lang})
if $verbose;
- system ("msgmerge","-U",$po_filename{$lang},$pot_filename) == 0 ||
- die sprintf(gettext("Error while running msgmerge: %s"),$!)."\n";
+ system ("msgmerge -U ".$po_filename{$lang}." $pot_filename ".($verbose?"":">/dev/null 2>/dev/null"))
+ && die sprintf(gettext("Error while running msgmerge: %s"),$!)."\n";
system "msgfmt --statistics -v -o /dev/null ".$po_filename{$lang}
if $verbose;
} else {
@@ -324,9 +336,10 @@
}
# update all translations
-foreach my $master (keys %document) {
- LANG: foreach $lang (keys %{$document{$master}}) {
- next if $lang eq "format" || $lang =~ /^add_/;
+
+foreach $lang (sort keys %po_filename) {
+ DOC: foreach my $master (keys %document) {
+ next unless defined $document{$master}{$lang};
my $doc=Locale::Po4a::Chooser::new($document{$master}{'format'} ,%options);
@@ -341,19 +354,19 @@
my ($percent,$hit,$queries) = $doc->stats();
if ($percent<$threshold) {
- print STDERR sprintf(gettext("Discard the translation %s (only %s%% translated; need %s%%)."),
+ print STDERR sprintf(gettext("Discard %s (only %s%% translated; need %s%%)."),
$document{$master}{$lang},$percent,$threshold)."\n";
unlink($document{$master}{$lang}) if (-e $document{$master}{$lang});
- next LANG;
+ next DOC;
}
if (defined ($document{$master}{"add_$lang"})) {
- foreach my $add ($document{$master}{"add_$lang"}) {
- if ( !$doc->addendum($_) ) {
+ foreach my $add (@{$document{$master}{"add_$lang"}}) {
+ if ( !$doc->addendum($add) ) {
die sprintf(gettext("Addendum %s does apply to %s (translation discarded)."),
$add,$document{$master}{$lang})."\n";
unlink($document{$master}{$lang}) if (-e $document{$master}{$lang});
- next LANG;
+ next DOC;
}
}
}
20 years, 5 months
[Po4a-devel][CVS] po4a po4a,1.7,1.8
by Martin Quinson
Update of /cvsroot/po4a/po4a
In directory haydn:/tmp/cvs-serv28913
Modified Files:
po4a
Log Message:
Fix last change; make error message look nice
Index: po4a
===================================================================
RCS file: /cvsroot/po4a/po4a/po4a,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- po4a 18 Jul 2004 06:42:40 -0000 1.7
+++ po4a 18 Jul 2004 07:15:16 -0000 1.8
@@ -261,14 +261,14 @@
$document{$main}{'format'} = $1;
foreach my $arg (split(/ /,$args)) {
die sprintf("%s:%d: ".
- gettext("The translated and master file are the same."),
- $config_file,$nb)
- if ($main eq $2);
- die sprintf("%s:%d: ".
gettext("Unparsable argument '%s'").
"\n",
$config_file,$nb,$arg)
unless ($arg =~ /^([^:]*):(.*)/);
+ die sprintf("%s:%d: ".
+ gettext("The translated and master file are the same."),
+ $config_file,$nb)
+ if ($main eq $2);
$document{$main}{$1} = $2;
}
@@ -357,9 +357,15 @@
}
}
}
- print STDERR sprintf(gettext("%s is %s%% translated (%s of %s strings)."),
- $document{$master}{$lang},$percent,$hit,$queries)."\n"
- if $verbose;
+ if ($verbose) {
+ if ($percent == 100) {
+ print STDERR sprintf(gettext("%s is %s%% translated (%s strings)."),
+ $document{$master}{$lang},$percent,$queries)."\n";
+ } else {
+ print STDERR sprintf(gettext("%s is %s%% translated (%s of %s strings)."),
+ $document{$master}{$lang},$percent,$hit,$queries)."\n";
+ }
+ }
$doc->write($document{$master}{$lang});
}
20 years, 5 months
[Po4a-devel][CVS] po4a po4a,1.6,1.7
by Martin Quinson
Update of /cvsroot/po4a/po4a
In directory haydn:/tmp/cvs-serv9860
Modified Files:
po4a
Log Message:
DO NOT OUTPUT TO ARRAY(something), MORON; detect moron like me trying to overwrite their master file by giving their name as translation; display the name of the translation in the message instead of master
Index: po4a
===================================================================
RCS file: /cvsroot/po4a/po4a/po4a,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- po4a 18 Jul 2004 06:27:25 -0000 1.6
+++ po4a 18 Jul 2004 06:42:40 -0000 1.7
@@ -261,11 +261,15 @@
$document{$main}{'format'} = $1;
foreach my $arg (split(/ /,$args)) {
die sprintf("%s:%d: ".
+ gettext("The translated and master file are the same."),
+ $config_file,$nb)
+ if ($main eq $2);
+ die sprintf("%s:%d: ".
gettext("Unparsable argument '%s'").
"\n",
$config_file,$nb,$arg)
unless ($arg =~ /^([^:]*):(.*)/);
- push @{$document{$main}{$1}},$2;
+ $document{$main}{$1} = $2;
}
} else {
@@ -337,8 +341,8 @@
my ($percent,$hit,$queries) = $doc->stats();
if ($percent<$threshold) {
- print STDERR sprintf(gettext("Discard the translation of %s (only %s%% translated; need %s%%)."),
- $master,$percent,$threshold)."\n";
+ print STDERR sprintf(gettext("Discard the translation %s (only %s%% translated; need %s%%)."),
+ $document{$master}{$lang},$percent,$threshold)."\n";
unlink($document{$master}{$lang}) if (-e $document{$master}{$lang});
next LANG;
}
@@ -347,14 +351,14 @@
foreach my $add ($document{$master}{"add_$lang"}) {
if ( !$doc->addendum($_) ) {
die sprintf(gettext("Addendum %s does apply to %s (translation discarded)."),
- $add,$master)."\n";
+ $add,$document{$master}{$lang})."\n";
unlink($document{$master}{$lang}) if (-e $document{$master}{$lang});
next LANG;
}
}
}
print STDERR sprintf(gettext("%s is %s%% translated (%s of %s strings)."),
- $master,$percent,$hit,$queries)."\n"
+ $document{$master}{$lang},$percent,$hit,$queries)."\n"
if $verbose;
$doc->write($document{$master}{$lang});
20 years, 5 months
[Po4a-devel][CVS] po4a po4a,1.5,1.6
by Martin Quinson
Update of /cvsroot/po4a/po4a
In directory haydn:/tmp/cvs-serv8837
Modified Files:
po4a
Log Message:
Add a -k option to po4a; polish some more messages
Index: po4a
===================================================================
RCS file: /cvsroot/po4a/po4a/po4a,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- po4a 18 Jul 2004 06:12:01 -0000 1.5
+++ po4a 18 Jul 2004 06:27:25 -0000 1.6
@@ -82,6 +82,12 @@
=over 4
+=item -k, --keep
+
+Minimal threshold for translation percentage to keep (ie, write) the
+resulting file (default: 80). Ie, by default, files have to be translated
+at at least 80% to get written.
+
=item -h, --help
Show a short help message.
@@ -175,12 +181,14 @@
my ($help,$type,$debug,$verbose,$quiet,@options);
$verbose = 0;
$debug = 0;
+my ($threshold)=(80);
Getopt::Long::config('bundling', 'no_getopt_compat', 'no_auto_abbrev');
GetOptions(
'help|h' => \$help,
'verbose|v' => \$verbose,
'debug|d' => \$debug,
'quiet|q' => \$quiet,
+ 'keep|k=s' => \$threshold,
'version|V' => \&show_version
) or pod2usage(1);
@@ -297,7 +305,7 @@
my $lang;
foreach $lang (sort keys %po_filename) {
if (-e $po_filename{$lang}) {
- print STDERR sprintf(gettext("Updating %s:")."\n",$po_filename{$lang})
+ print STDERR sprintf(gettext("Updating %s: "),$po_filename{$lang})
if $verbose;
system ("msgmerge","-U",$po_filename{$lang},$pot_filename) == 0 ||
die sprintf(gettext("Error while running msgmerge: %s"),$!)."\n";
@@ -328,9 +336,9 @@
my ($percent,$hit,$queries) = $doc->stats();
- if ($percent<80) {
- print STDERR sprintf(gettext("Translation of %s discarded: only %s%% are translated."),
- $master,$percent)."\n";
+ if ($percent<$threshold) {
+ print STDERR sprintf(gettext("Discard the translation of %s (only %s%% translated; need %s%%)."),
+ $master,$percent,$threshold)."\n";
unlink($document{$master}{$lang}) if (-e $document{$master}{$lang});
next LANG;
}
@@ -345,6 +353,10 @@
}
}
}
+ print STDERR sprintf(gettext("%s is %s%% translated (%s of %s strings)."),
+ $master,$percent,$hit,$queries)."\n"
+ if $verbose;
+
$doc->write($document{$master}{$lang});
}
}
20 years, 5 months
[Po4a-devel][CVS] po4a po4a,1.4,1.5
by Martin Quinson
Update of /cvsroot/po4a/po4a
In directory haydn:/tmp/cvs-serv1155
Modified Files:
po4a
Log Message:
Avoid the shame of writing our output files to something like ARRAY(0x83f01dc) ; syntax error around addendums ; try to apply addendum only when we have some; :-/
Index: po4a
===================================================================
RCS file: /cvsroot/po4a/po4a/po4a,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- po4a 18 Jul 2004 06:02:53 -0000 1.4
+++ po4a 18 Jul 2004 06:12:01 -0000 1.5
@@ -318,13 +318,12 @@
my $doc=Locale::Po4a::Chooser::new($document{$master}{'format'} ,%options);
- my (@file_in_name,@file_out_name,@po_in_name);
+ my (@file_in_name,@po_in_name);
push @file_in_name, $master;
- push @file_out_name, $document{$master}{$lang};
push @po_in_name, $po_filename{$lang};
$doc->process('file_in_name' => \@file_in_name,
- 'file_out_name' => \@file_out_name,
+ 'file_out_name' => $document{$master}{$lang},
'po_in_name' => \@po_in_name);
my ($percent,$hit,$queries) = $doc->stats();
@@ -336,12 +335,14 @@
next LANG;
}
- foreach my $add ($document{$master}{add_$lang}) {
- if ( !$doc->addendum($_) ) {
- die sprintf(gettext("Addendum %s does apply to %s (translation discarded)."),
- $add,$master)."\n";
- unlink($document{$master}{$lang}) if (-e $document{$master}{$lang});
- next LANG;
+ if (defined ($document{$master}{"add_$lang"})) {
+ foreach my $add ($document{$master}{"add_$lang"}) {
+ if ( !$doc->addendum($_) ) {
+ die sprintf(gettext("Addendum %s does apply to %s (translation discarded)."),
+ $add,$master)."\n";
+ unlink($document{$master}{$lang}) if (-e $document{$master}{$lang});
+ next LANG;
+ }
}
}
$doc->write($document{$master}{$lang});
20 years, 5 months
[Po4a-devel][CVS] po4a/lib/Locale/Po4a TransTractor.pm,1.23,1.24
by Martin Quinson
Update of /cvsroot/po4a/po4a/lib/Locale/Po4a
In directory haydn:/tmp/cvs-serv1002/lib/Locale/Po4a
Modified Files:
TransTractor.pm
Log Message:
So speak confucius: Always try to compile your file before commiting, little scarabee, it will avoid you a double shame
Index: TransTractor.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/TransTractor.pm,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- TransTractor.pm 18 Jul 2004 06:08:26 -0000 1.23
+++ TransTractor.pm 18 Jul 2004 06:10:24 -0000 1.24
@@ -533,7 +533,7 @@
unless ($filename) {
warn(dgettext("po4a",
- "Can't insert addendum when not given the filename")."\n")
+ "Can't insert addendum when not given the filename")."\n");
return 0;
}
20 years, 5 months
[Po4a-devel][CVS] po4a/lib/Locale/Po4a TransTractor.pm,1.22,1.23
by Martin Quinson
Update of /cvsroot/po4a/po4a/lib/Locale/Po4a
In directory haydn:/tmp/cvs-serv881/lib/Locale/Po4a
Modified Files:
TransTractor.pm
Log Message:
Warning when the addendum name is omited is good, but we should return instead of proceeding anyway (and die in awfull way)
Index: TransTractor.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/TransTractor.pm,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- TransTractor.pm 16 Jul 2004 23:15:15 -0000 1.22
+++ TransTractor.pm 18 Jul 2004 06:08:26 -0000 1.23
@@ -531,9 +531,11 @@
sub addendum {
my ($self,$filename) = @_;
- warn(dgettext("po4a",
- "Can't insert addendum when not given the filename")."\n")
- unless $filename;
+ unless ($filename) {
+ warn(dgettext("po4a",
+ "Can't insert addendum when not given the filename")."\n")
+ return 0;
+ }
my ($errcode,$mode,$position,$boundary,$bmode,$lang,$content)=
addendum_parse($filename);
20 years, 5 months