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'}