[Po4a-commits] "po4a/lib/Locale/Po4a Man.pm,1.111,1.112"

Nicolas FRANCOIS nekral-guest at alioth.debian.org
Sat Sep 24 19:13:47 UTC 2005


Update of /cvsroot/po4a/po4a/lib/Locale/Po4a
In directory haydn:/tmp/cvs-serv30776/lib/Locale/Po4a

Modified Files:
	Man.pm 
Log Message:
Replace the verbatim_groff_code and translate_groff_code options by an
unique groff_code option, which can take the fail (default), verbatim and
translate values.
(Idea stolen to Martin.)


Index: Man.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Man.pm,v
retrieving revision 1.111
retrieving revision 1.112
diff -u -d -r1.111 -r1.112
--- Man.pm	3 Sep 2005 18:22:40 -0000	1.111
+++ Man.pm	24 Sep 2005 19:13:45 -0000	1.112
@@ -118,18 +118,33 @@
 
 Increase verbosity.
 
-=item B<verbatim_groff_code>
+=item B<groff_code>
 
-With this option, the .de, .ie or .if sections are copied as is from the
-original to the translated document.
+This option permits to change the behavior of the module when it encounter
+a .de, .ie or .if section. It can take the following values:
 
-=item B<translate_groff_code>
+=over
 
-With this option, the .de, .ie or .if sections will be proposed for the
-translation. You should only use this option if a translatable string is
-contained in one of these section. Otherwise, B<verbatim_groff_code>
+=item I<fail>
+
+This is the default value.
+The module will fail when a .de, .ie or .if section is encountered.
+
+=item I<verbatim>
+
+Indicates that the .de, .ie or .if sections must be copied copied as is
+from the original to the translated document.
+
+=item I<translate>
+
+Indicates that the .de, .ie or .if sections will be proposed for the
+translation.
+You should only use this option if a translatable string is
+contained in one of these section. Otherwise, I<verbatim>
 should be preferred.
 
+=back
+
 =item B<untranslated>
 
 =item B<noarg>
@@ -374,9 +389,9 @@
 
 
 ######## CONFIG #########
-# These variables indicate if the associated options were activated.
-my $translate_groff_code;
-my $verbatim_groff_code;
+# This variable indicates the behavior of the module when a .de, .if or
+# .ie is encountered.
+my $groff_code = "fail";
 # %no_wrap_begin and %no_wrap_end are lists of macros that respectively
 # begins and ends a no_wrap paragraph.
 # Any ending macro will end the no_wrap paragraph started by any beginning
@@ -399,8 +414,7 @@
 
     $self->{options}{'debug'}='';
     $self->{options}{'verbose'}='';
-    $self->{options}{'translate_groff_code'}='';
-    $self->{options}{'verbatim_groff_code'}='';
+    $self->{options}{'groff_code'}='';
     $self->{options}{'untranslated'}='';
     $self->{options}{'noarg'}='';
     $self->{options}{'translate_joined'}='';
@@ -426,15 +440,8 @@
         }
     }
 
-    if (defined $options{'translate_groff_code'}) {
-        $translate_groff_code = 1;
-    } else {
-        $translate_groff_code = 0;
-    }
-    if (defined $options{'verbatim_groff_code'}) {
-        $verbatim_groff_code = 1;
-    } else {
-        $verbatim_groff_code = 0;
+    if (defined $options{'groff_code'}) {
+        $groff_code = $options{'groff_code'};
     }
 
     if (defined $options{'untranslated'}) {
@@ -1640,7 +1647,7 @@
 $macro{'ad'}=\&untranslated;
 # .de macro Define or redefine macro until .. is encountered.
 $macro{'de'}=sub {
-    if ($verbatim_groff_code or $translate_groff_code) {
+    if ($groff_code ne "fail") {
         my $self = shift;
         my $paragraph = "@_";
         my $end = ".";
@@ -1658,7 +1665,7 @@
             }
         }
         $paragraph .= "\n";
-        if ($verbatim_groff_code) {
+        if ($groff_code eq "verbatim") {
             $self->pushline($paragraph);
         } else {
             $self->pushline( $self->translate($paragraph,
@@ -1706,7 +1713,7 @@
 # .ie cond anything  If cond then anything else goto .el.
 # .if cond anything  If cond then anything; otherwise do nothing.
 $macro{'ie'}=$macro{'if'}=sub {
-    if ($verbatim_groff_code or $translate_groff_code) {
+    if ($groff_code ne "fail") {
         my $self = shift;
         my $m = $_[0];
         my $paragraph = "@_";
@@ -1741,7 +1748,7 @@
             $paragraph .= "\n".$paragraph2;
         }
         $paragraph .= "\n";
-        if ($verbatim_groff_code) {
+        if ($groff_code eq "verbatim") {
             $self->pushline($paragraph);
         } else {
             $self->pushline( $self->translate($paragraph,




More information about the Po4a-commits mailing list