[Po4a-commits] r2571 - in /trunk: lib/Locale/Po4a/Po.pm po4a po4a-updatepo

barbier-guest at users.alioth.debian.org barbier-guest at users.alioth.debian.org
Sun Sep 9 10:24:30 UTC 2012


Author: barbier-guest
Date: Sun Sep  9 10:24:30 2012
New Revision: 2571

URL: http://svn.debian.org/wsvn/po4a/?sc=1&rev=2571
Log:
porefs: Add a wrap/nowrap optional specifier

By default, po4a does not wrap file locations.  This is a bad idea,
because gettext tools do wrap them.  But if we modify this behavior,
most generated PO files are modified, which will cause trouble
when developers with different versions of po4a make changes.
So the --porefs has been extended, its syntax is now
  (full|none|noline)(,(wrap|nowrap))?
Default is "full,nowrap".  In some months (years?), we will change
this default to "full,wrap".

Modified:
    trunk/lib/Locale/Po4a/Po.pm
    trunk/po4a
    trunk/po4a-updatepo

Modified: trunk/lib/Locale/Po4a/Po.pm
URL: http://svn.debian.org/wsvn/po4a/trunk/lib/Locale/Po4a/Po.pm?rev=2571&op=diff
==============================================================================
--- trunk/lib/Locale/Po4a/Po.pm (original)
+++ trunk/lib/Locale/Po4a/Po.pm Sun Sep  9 10:24:30 2012
@@ -51,12 +51,19 @@
 
 =over 4
 
-=item B<porefs> I<type>
+=item B<porefs> I<type>[,B<wrap>|B<nowrap>]
 
 Specify the reference format. Argument I<type> can be one of B<none> to not
 produce any reference, B<noline> to not specify the line number (more
 accurately all line numbers are replaced by 1), and B<full> to include complete
 references.
+
+Argument can be followed by a comma and either B<wrap> or B<nowrap> keyword.
+References are written by default on a single line.  The B<wrap> option wraps
+references on several lines, to mimic B<gettext> tools (B<xgettext> and
+B<msgmerge>).  This option will become the default in a future release, because
+it is more sensible.  The B<nowrap> option is available so that users who want
+to keep the old behavior can do so.
 
 =item B<--msgid-bugs-address> I<email at address>
 
@@ -169,7 +176,7 @@
     chomp $date;
 #    $options = ref($options) || $options;
 
-    $self->{options}{'porefs'}= 'full';
+    $self->{options}{'porefs'}= 'full,nowrap';
     $self->{options}{'msgid-bugs-address'}= undef;
     $self->{options}{'copyright-holder'}= "Free Software Foundation, Inc.";
     $self->{options}{'package-name'}= "PACKAGE";
@@ -182,7 +189,7 @@
             $self->{options}{$opt} = $options->{$opt};
         }
     }
-    $self->{options}{'porefs'} =~ /^(full|noline|none)$/ ||
+    $self->{options}{'porefs'} =~ /^(full|noline|none)(,(no)?wrap)?$/ ||
         die wrap_mod("po4a::po",
                      dgettext ("po4a",
                                "Invalid value for option 'porefs' ('%s' is ".
@@ -448,9 +455,15 @@
         $output .= format_comment($self->{po}{$msgid}{'type'},". type: ")
             if    defined($self->{po}{$msgid}{'type'})
                && length ($self->{po}{$msgid}{'type'});
-        $output .= format_comment($self->{po}{$msgid}{'reference'},": ")
-            if    defined($self->{po}{$msgid}{'reference'})
-               && length ($self->{po}{$msgid}{'reference'});
+        if (   defined($self->{po}{$msgid}{'reference'})
+            && length ($self->{po}{$msgid}{'reference'})) {
+            my $output_ref = $self->{po}{$msgid}{'reference'};
+            if ($self->{options}{'porefs'} =~ m/,wrap$/) {
+                $output_ref = wrap($output_ref);
+                $output_ref =~ s/\s+$//mg;
+            }
+            $output .= format_comment($output_ref,": ");
+        }
         $output .= "#, ". join(", ", sort split(/\s+/,$self->{po}{$msgid}{'flags'}))."\n"
             if    defined($self->{po}{$msgid}{'flags'})
                && length ($self->{po}{$msgid}{'flags'});
@@ -1240,9 +1253,9 @@
         return;
     }
 
-    if ($self->{options}{'porefs'} eq "none") {
+    if ($self->{options}{'porefs'} =~ m/^none/) {
         $reference = "";
-    } elsif ($self->{options}{'porefs'} eq "noline") {
+    } elsif ($self->{options}{'porefs'} =~ m/^noline/) {
         $reference =~ s/:[0-9]*/:1/g;
     }
 

Modified: trunk/po4a
URL: http://svn.debian.org/wsvn/po4a/trunk/po4a?rev=2571&op=diff
==============================================================================
--- trunk/po4a (original)
+++ trunk/po4a Sun Sep  9 10:24:30 2012
@@ -418,12 +418,19 @@
 
 =over 4
 
-=item B<porefs> I<type>
+=item B<porefs> I<type>[,B<wrap>|B<nowrap>]
 
 Specify the reference format. Argument I<type> can be one of B<none> to not
 produce any reference, B<noline> to not specify the line number (more
 accurately all line numbers are replaced by 1), and B<full> to include complete
 references.
+
+Argument can be followed by a comma and either B<wrap> or B<nowrap> keyword.
+References are written by default on a single line.  The B<wrap> option wraps
+references on several lines, to mimic B<gettext> tools (B<xgettext> and
+B<msgmerge>).  This option will become the default in a future release, because
+it is more sensible.  The B<nowrap> option is available so that users who want
+to keep the old behavior can do so.
 
 =item B<--msgid-bugs-address> I<email at address>
 

Modified: trunk/po4a-updatepo
URL: http://svn.debian.org/wsvn/po4a/trunk/po4a-updatepo?rev=2571&op=diff
==============================================================================
--- trunk/po4a-updatepo (original)
+++ trunk/po4a-updatepo Sun Sep  9 10:24:30 2012
@@ -103,12 +103,19 @@
 
 Output some debugging information.
 
-=item B<porefs> I<type>
+=item B<porefs> I<type>[,B<wrap>|B<nowrap>]
 
 Specify the reference format. Argument I<type> can be one of B<none> to not
 produce any reference, B<noline> to not specify the line number (more
 accurately all line numbers are replaced by 1), and B<full> to include complete
 references.
+
+Argument can be followed by a comma and either B<wrap> or B<nowrap> keyword.
+References are written by default on a single line.  The B<wrap> option wraps
+references on several lines, to mimic B<gettext> tools (B<xgettext> and
+B<msgmerge>).  This option will become the default in a future release, because
+it is more sensible.  The B<nowrap> option is available so that users who want
+to keep the old behavior can do so.
 
 =item B<--msgid-bugs-address> I<email at address>
 




More information about the Po4a-commits mailing list