[Po4a-devel] [PATCH] Some patches for the Po4a's Wml module

Kobayashi Noritada nori1 at dolphin.c.u-tokyo.ac.jp
Thu Feb 28 10:10:25 UTC 2008


Hi,

I am working as a Japanese translator for Debian's web site and
considering whether we can handle translations in wml files with po
files.  I don't think the current way of maintaining web page
translations is good since all the translations must be hard-coded in
the wml files, linked with CVS revisions and block-level markups.  So,
I'm paying attention to the Po4a's Wml module.  I have used Po4a for
translations of release notes and aptitude, and like the idea of that
software. ;-)

Since the Wml module seems to be still immature and somewhat buggy, I
provide some patches here.  Could you please review and commit them?
# Or, shall I participate in this project and commit by myself? ;-)

Descriptions are below:

replacement.patch:
  Correct a mistake: do replacing instead of matching.
  Patch by: Kenshi Muto <kmuto at debian.org>

define-tag.patch:
  Enable handling define-tag tags.
  Patch by: Noritada Kobayashi <nori1 at dolphin.c.u-tokyo.ac.jp>

charset.patch:
  Enable handling input file charset correctly.
  Patch by: Noritada Kobayashi <nori1 at dolphin.c.u-tokyo.ac.jp>

I know these patches are not enough for making the Wml module usable.
I'd love to create more patches and try to make the Wml module
suitable for handling all pages in Debian's web site.

Thanks,

-nori
-------------- next part --------------
--- lib/Locale/Po4a/Wml.pm.orig	2008-02-28 18:48:23.000000000 +0900
+++ lib/Locale/Po4a/Wml.pm	2008-02-28 18:48:35.000000000 +0900
@@ -104,7 +104,7 @@
       }
 
       # Mask mp4h cruft         
-      while ($file =~ m|^#(.*)$|<!--PO4ASHARPBEGIN$1PO4ASHARPEND-->|m) {
+      while ($file =~ s|^#(.*)$|<!--PO4ASHARPBEGIN$1PO4ASHARPEND-->|m) {
         my $line = $1;
         print STDERR "PROTECT HEADER: $line\n";
         if ($line =~ m/title="([^"]*)"/) { #) {#"){
-------------- next part --------------
--- lib/Locale/Po4a/Wml.pm.orig	2008-02-28 18:49:37.000000000 +0900
+++ lib/Locale/Po4a/Wml.pm	2008-02-28 18:51:59.000000000 +0900
@@ -111,6 +111,9 @@
           warn "FIXME: We should translate the page title: $1\n";
         }          
       }
+
+      # Validate define-tag tag's argument
+      $file =~ s|(<define-tag\s+)([^\s>]+)|$1PO4ADUMMYATTR="$2"|g;
                 
       # Flush the result to disk          
       open OUTFILE,">$tmp_filename";
@@ -136,6 +139,7 @@
       $file = join("",@{$xmlizer->{TT}{doc_out}});
       $file =~ s/^<!--PO4ASHARPBEGIN(.*?)PO4ASHARPEND-->/#$1/mg;
       $file =~ s/<!--PO4ABEGINPERL(.*?)PO4AENDPERL-->/<:$1:>/msg;
+      $file =~ s|(<define-tag\s+)PO4ADUMMYATTR="([^"]*)"|$1$2|g;
       $file =~ s/PO4ALT/</msg;
       $file =~ s/PO4AGT/>/msg;
 
-------------- next part --------------
--- lib/Locale/Po4a/Wml.pm.orig	2008-02-28 18:51:59.000000000 +0900
+++ lib/Locale/Po4a/Wml.pm	2008-02-28 18:52:42.000000000 +0900
@@ -123,6 +123,7 @@
       
       # Build the XML TransTractor which will do the job for us
       my $xmlizer = Locale::Po4a::Chooser::new("xhtml");
+      $xmlizer->{TT}{'file_in_charset'}=$self->{TT}{'file_in_charset'};
       $xmlizer->{TT}{po_in}=$self->{TT}{po_in};
       $xmlizer->{TT}{po_out}=$self->{TT}{po_out};
       


More information about the Po4a-devel mailing list