[Po4a-devel]Add an option to tweak po references
by Francois Gouget
Currently the po references contain the file and line number:
#: ../wine-user-en-sgml/wine-user.sgml:82
../wine-user-en-sgml/glossary.sgml:171
What this means is that if someone adds a line near the beginning of
wine-user.sgml we will get thousands of lines of diff the next time
po4a-updatepo is run.
I know po tools can probably hide this issue from users (though that
doesn't help me since I use xemacs) but this is still going to be a
problem when comparing two CVS version of the po file. This is also a
big nuisance when trying to merge CVS branches. Look at the output of
the following command to see what I mean:
cvs diff -r1.4 -r1.5 po/pod/fr.po
Also I feel that references that include the line number are less useful
when translating documentation than when translating the strings used in
a program. The strings in a program are often pretty short, sometimes a
single word like 'Close' and searching for such strings is difficult due
to false positives. Thus for programs the line number information is
quite useful. But, when translating the documentation, each msgid is a
paragraph which usually contains at least a full sentence. So it's easy
to find the relevant place in the source SGML file by searching for a
sequence of two or three words.
So I propose to add a 'porefs' option to po4a-updatepo which would allow
the user to control the addition of references. It would have three
possible values:
* none
No references are added
* noline
References are added but all line numbers are set to '1'. I'm
keeping a line number for compatibility with po tools let the user open
the relevant file by double clicking on the reference.
* full
This would be the default and work just as it does today.
Now, the logical place to implement this is the Po.pm module but it was
not possible to pass options to it. So I added a -O option which passes
options to the Po.pm module (via TransTractor,pm) instead of the format
module.
Let me know if this sounds ok or if another approach should be used.
Changelog:
* po4a-updatepo
lib/Locale/Po4a/TransTractor.pm
lib/Locale/Po4a/Po.pm
Francois Gouget <fgouget(a)codeweavers.com>
Add a porefs option to let the user customize the generation of po
references.
Add a -O option to po4a-updatepo so users can pass options to the
Po,pm module.
--
Francois Gouget
fgouget(a)codeweavers.com
Index: po4a-updatepo
===================================================================
RCS file: /cvsroot/po4a/po4a/po4a-updatepo,v
retrieving revision 1.36
diff -u -p -r1.36 po4a-updatepo
--- po4a-updatepo 30 May 2005 07:13:38 -0000 1.36
+++ po4a-updatepo 28 Jun 2005 16:48:11 -0000
@@ -136,7 +136,7 @@ Getopt::Long::config('bundling', 'no_get
# Parse our options
my (@masterfiles,@pofiles);
-my ($help,$help_fmt,$verbose,$debug,$format,@options);
+my ($help,$help_fmt,$verbose,$debug,$format,@options,@po_options);
my $mastchar;
GetOptions('help|h' => \$help,
'help-format' => \$help_fmt,
@@ -148,6 +148,7 @@ GetOptions('help|h' => \$help,
'master-charset|M=s' => \$mastchar,
'option|o=s' => \@options,
+ 'O=s' => \@po_options,
'verbose|v' => \$verbose,
'debug|d' => \$debug,
@@ -169,6 +170,16 @@ foreach (@options) {
$options{$_}=1;
}
}
+
+my %po_options;
+foreach (@po_options) {
+ if (m/^([^=]*)=(.*)$/) {
+ $po_options{$1}="$2";
+ } else {
+ $po_options{$_}=1;
+ }
+}
+$options{'po_options'}=\%po_options;
# parser
my ($doc)=Locale::Po4a::Chooser::new($format,%options);
Index: lib/Locale/Po4a/TransTractor.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/TransTractor.pm,v
retrieving revision 1.67
diff -u -p -r1.67 TransTractor.pm
--- lib/Locale/Po4a/TransTractor.pm 30 May 2005 07:05:23 -0000 1.67
+++ lib/Locale/Po4a/TransTractor.pm 28 Jun 2005 16:48:13 -0000
@@ -330,7 +331,8 @@ sub new {
# private data
$self->{TT}=();
$self->{TT}{po_in}=Locale::Po4a::Po->new();
- $self->{TT}{po_out}=Locale::Po4a::Po->new();
+ $self->{TT}{po_out}=Locale::Po4a::Po->new($options{'po_options'});
+ delete $options{'po_options'};
# Warning, this is an array of array:
# The document is splited on lines, and for each
# [0] is the line content, [1] is the reference [2] the type
Index: lib/Locale/Po4a/Po.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Po.pm,v
retrieving revision 1.43
diff -u -p -r1.43 Po.pm
--- lib/Locale/Po4a/Po.pm 30 May 2005 07:15:21 -0000 1.43
+++ lib/Locale/Po4a/Po.pm 28 Jun 2005 16:48:12 -0000
@@ -46,6 +46,16 @@ translate everything, including document
package description, debconf templates, and everything which may benefit
from this.
+=head1 OPTIONS ACCEPTED BY THIS MODULE
+
+=over 4
+
+=item porefs
+
+This specifies the reference format. It can be one of 'none' to not produce
+any reference, 'noline' to not specify the line number, and 'full' to
+include complete references.
+
=cut
@@ -93,11 +103,11 @@ a po file we should load.
=cut
sub new {
- my $this = shift;
+ my ($this, $options) = (shift, shift);
my $class = ref($this) || $this;
my $self = {};
bless $self, $class;
- $self->initialize();
+ $self->initialize($options);
my $filename = shift;
$self->read($filename) if defined($filename) && length($filename);
@@ -105,10 +115,18 @@ sub new {
}
sub initialize {
- my $self = shift;
+ my ($self, $options) = (shift, shift);
my $date = `date +'%Y-%m-%d %k:%M%z'`;
chomp $date;
+ $self->{options}{'porefs'}= 'full';
+ foreach my $opt (keys %$options) {
+ if ($options->{$opt}) {
+ die wrap_mod("po4a::po", dgettext ("po4a", "Unknown option: %s"), $opt) unless exists $self->{options}{$opt};
+ $self->{options}{$opt} = $options->{$opt};
+ }
+ }
+
$self->{po}=();
$self->{count}=0;
$self->{header_comment}=
@@ -641,7 +659,7 @@ sub gettext {
my $res;
return "" unless defined($text) && length($text); # Avoid returning the header.
- my $validoption="wrap wrapcol";
+ my $validoption="reference wrap wrapcol";
my %validoption;
map { $validoption{$_}=1 } (split(/ /,$validoption));
@@ -850,7 +868,13 @@ sub push_raw {
$self->{header_comment}=$comment;
return;
}
-
+
+ if ($self->{options}{'porefs'} eq "none") {
+ $reference = "";
+ } elsif ($self->{options}{'porefs'} eq "noline") {
+ $reference =~ s/:[0-9]*/:1/g;
+ }
+
if (defined($self->{po}{$msgid})) {
warn wrap_mod("po4a::po", dgettext("po4a","msgid defined twice: %s"), $msgid) if (0); # FIXME: put a verbose stuff
if ($msgstr && $self->{po}{$msgid}{'msgstr'}
19 years, 4 months
[Po4a-devel]Unrecognized prolog inclusion entity
by Francois Gouget
I have an SGML file which essentially does this:
<!doctype book PUBLIC "-//OASIS//DTD DocBook V3.1//EN" [
<!ENTITY % foo "INCLUDE">
<![ %foo; [
<!entity some-chapter SYSTEM "some-chapter.sgml">
]]>
]>
...
And this triggers the 'unrecognized prolog inclusion entity' error at
line 539 of Sgml.pm.
Now, before you ask, this document is in fact generated automatically
and the 'foo' entity is either set to 'INCLUDE' or 'IGNORE' depending on
what we want to do with the generic document, and the idea behind the
conditional include is to not include sgml files we will not use.
This works fine with DocBook and it worked fine with Po4a 0.16.2.
So I tried to understand why it does not work with the current Po4a code
and I came to the conclusion that putting conditional sections in the
prolog is simply not supported by the current code. Did I come to the
correct conclusion? Would it be easy to fix?
The alternative is to remove the conditional sections from the prolog.
That fixes the Po4a error and I think it should not cause other issues.
But I'd prefer to fix/improve po4a if possible.
--
Francois Gouget
fgouget(a)codeweavers.com
19 years, 4 months
[Po4a-devel]'msgid skipped' warnings
by Francois Gouget
I'm a annoyed by the 'msgid skipped' warnings for two reasons:
1) they don't give me any line information so I have no way of
checking the source Sgml file to verify whether po4a did the right thing
or not. This makes them completely useless.
2) I can understand po4a-updatepo issuing this warning but should
po4a-translate really issue this warning too?
I have fixed issue 1 by including the reference in the warning. An
alternative would be to issue this warning only once and to tell the
user to set the 'include-all' option if he wants to get all the msgids.
I'm dithering on issue 2. Initially I thought po4a-translate had no
reason to issue this warning since it's not generating a po file. But
then if the po file contains 'translations' for these msgids but
po4a-translate skips them anyway you'd probably want to know.
Maybe the solution to issue 2 is to be able to set 'include-all=no' to
indicate that you know some msgids are being skipped and you don't want
to see the warning.
Then maybe this means the right solution to issue 1 is really to only
issue the warning once and point the user to the 'include-all' option.
Any thoughts on this?
--
Francois Gouget
fgouget(a)codeweavers.com
19 years, 4 months
[Po4a-devel]Make attribute translation more flexible
by Francois Gouget
I was not completely happy with my previous attribute translation patch:
1) the user should be able to control whether he gets msgid "lang=en"
or msgid "en"
2) Sgml.pm should behave the same as Xml.pm by default, i.e. generate
msgid "en"
3) Xml.pm uses the 'attributes' option while Sgml.pm uses 'attribute'
So here is a patch which tries to address each of these issues:
3) The rational behind choosing 'attribute' for Sgml.pm was that the
other options are singular. But in fact they are not nouns so there's no
singular/plural consideration. Then it's not inconsistent to use
'attributes' and it would match Xml.pm so it would be better.
1) The idea is to have two options. The 'attributes' option determines
which attributes should be translated and in which context while the
'qualify' option determines which attributes should get a qualified msgid.
So 'attributes=lang' would generate msgid "en" while
'attributes=lang qualify=lang' would generate msgid "lang=en".
Note that the qualify option only takes a list of attribute names
without a tag context because it would be inconsistent to generate
different msgids for a given attribute depending on the context.
2) I modified Sgml.pm so the lang attribute is not qualified by default.
Further it would be nice to add the same capabilities to Xml.pm but I
had trouble figuring out how so it will go in a separate patch.
Changelog:
* lib/Locale/Po4a/Sgml.pm
Francois Gouget <fgouget(a)codeweavers.com>
Add a 'qualify' option to denote which attributes should get an
msgid 'qualified' by the attribute name.
Don't qualify the lang attribute for consistency with Xml.pm
Rename the 'attribute' option to 'attributes' for consistency with
Xml.pm.
--
Francois Gouget
fgouget(a)codeweavers.com
Index: lib/Locale/Po4a/Sgml.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Sgml.pm,v
retrieving revision 1.61
diff -u -p -r1.61 Sgml.pm
--- lib/Locale/Po4a/Sgml.pm 16 Jun 2005 19:24:25 -0000 1.61
+++ lib/Locale/Po4a/Sgml.pm 28 Jun 2005 16:48:12 -0000
@@ -82,7 +82,7 @@ they can be part of an msgid. For exampl
for this category since putting it in the translate section would create
msgids not being whole sentences, which is bad.
-=item attribute
+=item attributes
A space separated list of attributes that need to be translated. You can
specify the attributes by their name (for example, "lang"), but you can also
@@ -94,6 +94,12 @@ The tag names are actually regular expre
like E<lt>aaa|bbbbE<gt>lang to only translate lang attributes that are in
an E<lt>aaaE<gt> or a E<lt>bbbE<gt> tag.
+=item qualify
+
+A space separated list of attributes for which the translation must be
+qualified by the attribute name. Note that this setting only takes effect
+if the attribute is specified in the 'attributes' list too.
+
=item force
Proceed even if the DTD is unknown.
@@ -285,13 +291,13 @@ sub set_tags_kind {
my $self=shift;
my (%kinds)=@_;
- foreach (qw(translate empty section verbatim ignore attribute)) {
+ foreach (qw(translate empty section verbatim ignore attributes qualify)) {
$self->{SGML}->{k}{$_} = $self->{options}{$_} ? $self->{options}{$_}.' ' : '';
}
foreach (keys %kinds) {
die "po4a::sgml: internal error: set_tags_kind called with unrecognized arg $_"
- if ($_ !~ /^(translate|empty|verbatim|ignore|indent|attribute)$/);
+ if ($_ !~ /^(translate|empty|verbatim|ignore|indent|attributes|qualify)$/);
$self->{SGML}->{k}{$_} .= $kinds{$_};
}
@@ -438,7 +445,7 @@ sub parse_file {
"wordasword ".
"xref ".
"year",
- "attribute" => "<(article|book)>lang");
+ "attributes" =>"<(article|book)>lang");
} else {
if ($self->{options}{'force'}) {
@@ -628,7 +645,7 @@ sub parse_file {
open (IN,$cmd) || die wrap_mod("po4a::sgml", dgettext("po4a", "Can't run nsgmls: %s"), $!);
# The kind of tags
- my (%translate,%empty,%verbatim,%indent,%exist,%attribute);
+ my (%translate,%empty,%verbatim,%indent,%exist,%attribute,%qualify);
foreach (split(/ /, ($self->{SGML}->{k}{'translate'}||'') )) {
$translate{uc $_} = 1;
$indent{uc $_} = 1;
@@ -651,7 +668,7 @@ sub parse_file {
foreach (split(/ /, ($self->{SGML}->{k}{'ignore'}) || '')) {
$exist{uc $_} = 1;
}
- foreach (split(/ /, ($self->{SGML}->{k}{'attribute'}) || '')) {
+ foreach (split(/ /, ($self->{SGML}->{k}{'attributes'} || ''))) {
my ($attr, $tags);
if (m/(^.*>)(\w+)/)
{
@@ -672,6 +689,9 @@ sub parse_file {
$attribute{$attr} = $tags;
}
}
+ foreach (split(/ /, ($self->{SGML}->{k}{'qualify'}) || '')) {
+ $qualify{uc $_} = 1;
+ }
# What to do before parsing
@@ -737,8 +757,9 @@ sub parse_file {
if ($val->type() eq 'CDATA' ||
$val->type() eq 'IMPLIED') {
if (defined $value && length($value)) {
- my $name=lc $attr;
- if (exists $attribute{uc($attr)}) {
+ my $lattr=lc $attr;
+ my $uattr=uc $attr;
+ if (exists $attribute{$uattr}) {
my $context="";
foreach my $o (@open) {
next if (!defined $o or $o =~ m%^</%);
@@ -747,12 +768,16 @@ sub parse_file {
}
$context=join("", $context,
"<", lc($event->data->name()), ">");
- if ($context =~ /^($attribute{uc($attr)})$/) {
- my $translated = $self->translate("$name=$value", $ref, "attribute $context$name");
- if ($translated =~ s/^$name=//) {
- $value=$translated;
+ if ($context =~ /^($attribute{$uattr})$/) {
+ if ($qualify{$uattr}) {
+ my $translated = $self->translate("$lattr=$value", $ref, "attribute $context$lattr");
+ if ($translated =~ s/^$lattr=//) {
+ $value=$translated;
+ } else {
+ die wrap_mod("po4a::sgml", dgettext("po4a", "bad translation '%s' for '%s' in '%s'"), $translated, "$context$lattr", $ref);
+ }
} else {
- die wrap_mod("po4a::sgml", dgettext("po4a", "bad translation '%s' for '%s' in '%s'"), $translated, "$context$name", $ref);
+ $value = $self->translate($value, $ref, "attribute $context$lattr");
}
}
}
@@ -761,7 +786,7 @@ sub parse_file {
} else {
$value = '"'.$value.'"';
}
- $tag .= ' '.lc($attr).'='.$value;
+ $tag .= " $lattr=$value";
}
} elsif ($val->type() eq 'NOTATION') {
} else {
19 years, 4 months
$B!y!z0lK|1_J,%W%l%<%s%H!z!y(B
by info@yoshinoya-peri.com
http://awg.webchu.com/nanpara/?present1
$B=i$a$^$7$F!*!*FMA3$N%a!<%k$4LBOG$G$7$?$i$*5v$72<$5$$!#(B
$B?75,%5%$%HN)$A>e$2$KH<$$!"0lK|1_(B(1000$B%]%$%s%H(B)$BJ,%W%l%<%s%H$N$*CN$i$;$G$9!#(B
http://awg.webchu.com/nanpara/?present1
$B!X$^$?=P2q$$7O$+$!!Y$H;W$o$J$$$G2<$5$$!*!*!#(B
$B;dC#$b3'$5$s$HF1$8=P2q$$7O$K<:K>$7$F$$$?%f!<%6!<$G$7$?!#(B
$B!X$*6b$,@K$7$$$s$8$c$J$$!"0)$($J$$;v$,2y$7$$$s$@!*!Y(B
$B$=$3$G<+J,C#$G!XNI$$%5%$%H$r:n$m$&$8$c$J$$$+!*!Y$H;W$C$?Lu$G$9!#(B
$B0lK|1_(B(1000$B%]%$%s%H(B)$BJ,%W%l%<%s%H$O3'$5$s$X$N5$;}$A$G$9!#(B
http://awg.webchu.com/nanpara/?present1
$B;dC#$HNI$+$C$?:"$N=P2q$$7O$r<h$jLa$9$Y$-$G$9!*!#(B
$B@5D>!"NI$$%9%]%s%5!<$,8+$D$+$i$:B?>/M-NA2=$H$J$C$?$N$,;DG0$G$9!#(B
$B%9%?%C%U0lF1!"3'$5$s$HD9$$$*IU$-9g$$$,$G$-$k;v$r4uK>$7$^$9!#(B
http://awg.webchu.com/nanpara/?present1
$B:G8e$K0Y$j$^$9$,!"$3$N%a!<%k$NG[?.$r$rIT2w$^$?$OITMW$H;W$o$l$kJ}$O!"(B
$B$*<j?t$G$9$,2<5-%"%I%l%9Kx$*Aw$j2<$5$$$^$9$h$&$*4j$$?=$7>e$2$^$9!#(B
$BG[?.ITMW$O$3$A$iKx"*(B nanpara_office2(a)yahoo.co.jp
In an unnecessary delivery, even here is $B"*(B nanpara_office2(a)yahoo.co.jp
$BAw?.IT<{MW"*(B nanpara_office2(a)yahoo.co.jp
19 years, 4 months
[Po4a-devel][VAC] away until mid-july, at least
by Martin Quinson
Hello,
I leave in approximately half an hour for two weeks without net connexion.
Afterward, I'll have access from time to time only until something between
mi-august to end-august.
I'm sorry I wasn't able to review the recently submitted patches, neither to
implement what I promised about options. I will do so when I come back...
Have a good time,
Mt.
19 years, 4 months
[Po4a-devel]$B!y!z0lK|1_J,%W%l%<%s%H!z!y(B
by info@taro-soramame.com
$B=i$a$^$7$F!*!*FMA3%a!<%k$r:9$7>e$2$F$4LBOG$G$7$?$i$*5v$72<$5$$!#(B
$B?75,%5%$%HN)$A>e$2$KH<$$!"0lK|1_(B(1000$B%]%$%s%H(B)$BJ,%W%l%<%s%H$N$*CN$i$;$G$9!#(B
http://awg.webchu.com/nanpara/?user1
$B!X$^$?=P2q$$7O$+$!!Y$H;W$o$l$k$+$bCN$l$^$;$s$,!"$*BT$A2<$5$$!*!*!#(B
$B;dC#%9%?%C%U$b3'$5$s$HF1$8$/!":G=i$OC1$J$k%f!<%6!<$G$7$?!#(B
$B:G6a$N=P2q$$7O%5%$%H$NM>$j$K$b9s$$1?1D$K%&%s%6%j$7$F!"(B
$B<+J,C#$N<j$G%f!<%6!<$H0lBN$N!XNI$$%5%$%H$r:n$m$&$8$c$J$$$+!*!Y$H;W$$N)$C$?Lu$G$9!#(B
$B$7$+$7=P2q$$7O$O%$%a!<%8$,0-$/!"NI$$%9%]%s%5!<$,8+$D$+$i$:!"(B
$BM-NA2=$;$6$k=*$($J$+$C$?$N$,;DG0$G$9!#(B
http://awg.webchu.com/nanpara/?user1
$B0lK|1_(B(1000$B%]%$%s%H(B)$BJ,%W%l%<%s%H$O!";dC#$N3'$5$s$X$N5$;}$A$NI=8=$G$9!#(B
$B$3$l$O;dC#<+?H$N7P83B'$G$bM-$j$^$9$,!"(B
$B!X$-$A$s$H0)$($k$J$i!"B?>/$N$*6b$O@K$7$/$J$$!"B~!"0)$($J$$;v$,2y$7$$$s$@!*!Y(B
$B$=$l$,;dC#$NK\2;$8$cM-$j$^$;$s$+!)!#(B
$B$=$l$J$i;dC#$H0l=o$K!"NI$+$C$?:"$N=P2q$$7O$r<h$jLa$9$Y$-$G$9!*!#(B
http://awg.webchu.com/nanpara/?user1
$B3'$5$s$HB)$ND9$$$*IU$-9g$$$,$G$-$k;v$r!"%9%?%C%U0lF14uK>$7$F$*$j$^$9!#(B
19 years, 4 months