[Po4a-commits] "po4a/lib/Locale/Po4a Pod.pm, 1.18, 1.19 Sgml.pm, 1.107, 1.108"

Nicolas FRANCOIS nekral-guest at alioth.debian.org
Sun Mar 5 13:25:09 UTC 2006


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

Modified Files:
	Pod.pm Sgml.pm 
Log Message:
Convert non-breaking space characters to their representation in the Pod
or Sgml formats.


Index: Pod.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Pod.pm,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- Pod.pm	26 Oct 2005 10:53:25 -0000	1.18
+++ Pod.pm	5 Mar 2006 13:25:07 -0000	1.19
@@ -28,6 +28,42 @@
 
 sub initialize {}
 
+sub translate {
+    my ($self,$str,$ref,$type) = @_;
+    my (%options)=@_;
+
+    $str = $self->pre_trans($str,$ref,$type);
+    $str = $self->SUPER::translate($str, $ref, $type, %options);
+    $str = $self->post_trans($str,$ref,$type);
+
+    return $str;
+}
+
+sub pre_trans {
+    my ($self,$str,$ref,$type)=@_;
+
+    return $str;
+}
+
+sub post_trans {
+    my ($self,$str,$ref,$type)=@_;
+
+    # Change ascii non-breaking space to POD one
+    my $nbs_out = "\xA0";
+    my $enc_length = Encode::from_to($nbs_out, "latin1",
+                                               $self->get_out_charset);
+    if (defined $enc_length) {
+        while ($str =~ m/(^|.*\s)(\S+?)\Q$nbs_out\E(\S+?)(\s.*$|$)/) {
+            $str  = $1||"";
+            $str .= "S<$2 $3>";
+            $str .= $4||"";
+        }
+    }
+
+    return $str;
+}
+
+
 sub command {
     my ($self, $command, $paragraph, $line_num) = @_;
 #    print STDOUT "cmd: '$command' '$paragraph' at $line_num\n";
@@ -113,7 +149,7 @@
         *****************************************************
 
 This file was generated by po4a(7). Do not store it (in cvs, for example),
-but store the po file used as source file by pod-translate. 
+but store the po file used as source file by po4a-translate. 
 
 In fact, consider this as a binary, and the po file as a regular .c file:
 If the po get lost, keeping this translation up-to-date will be harder.

Index: Sgml.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Sgml.pm,v
retrieving revision 1.107
retrieving revision 1.108
diff -u -d -r1.107 -r1.108
--- Sgml.pm	23 Feb 2006 16:10:41 -0000	1.107
+++ Sgml.pm	5 Mar 2006 13:25:07 -0000	1.108
@@ -295,7 +295,23 @@
         return $string.($options{'wrap'}?"\n":"");
     }
 
-    return $self->SUPER::translate($string,$ref,$type,%options);
+    $string = $self->SUPER::translate($string,$ref,$type,%options);
+
+    $string = $self->post_trans($string,$ref,$type);
+
+    return $string;
+}
+
+sub post_trans {
+    my ($self,$str,$ref,$type)=@_;
+
+    # Change ascii non-breaking space to an &nbsp;
+    my $nbs_out = "\xA0";
+    my $enc_length = Encode::from_to($nbs_out, "latin1",
+                                               $self->get_out_charset);
+    $str =~ s/\Q$nbs_out/&nbsp;/g if defined $enc_length;
+
+    return $str;
 }
 
 #




More information about the Po4a-commits mailing list