Re: support for newlines in xml.in files



Hi Bruno,

Yesterday at 23:02, Bruno Coudoin wrote:

> Again from the gcompris folks. I have a few strings with newlines
> in .xml.in files. They are in the .po files but even translated, they
> never show up in our .xml
> I tested 

This is indeed the problem, but it's not about newlines, but rather
about "\n" sequences (or any of recognized "\x" sequences, such as \t,
\r, etc.).

The problem is in intltool-extract, type_xml function.  We'd need to
escape any messages with appropriate slashes, since "\n" is actually
used in PO strings to indicate real newlines (eg. with 
xml:space="preserve"; this might be even more interesting for you).

I've got a patch for this, but I need to test it (and add a test case)
before I'm able to commit it.  It's as simple as:

diff -u -r1.62 intltool-extract.in.in
--- intltool-extract.in.in      23 Oct 2004 09:11:26 -0000      1.62
+++ intltool-extract.in.in      18 Nov 2004 03:17:31 -0000
@@ -267,12 +267,15 @@
     ### For generic translatable XML files ###
         
     while ($input =~ /(?:<!--([^>]*?)-->[^\n]*\n?[^\n]*)?\s_$w+\s*=\s*\"([^"]+)\"/sg) { # "
-        $messages{entity_decode_minimal($2)} = [];
-        $comments{entity_decode_minimal($2)} = $1 if (defined($1));
+        $_ = $2;
+        s/\\/\\\\/g;
+        $messages{entity_decode_minimal($_)} = [];
+        $comments{entity_decode_minimal($_)} = $1 if (defined($1));
     }
 
     while ($input =~ /(?:<!--([^>]*?)-->\s*)?<_($w+)(?: xml:space="($w+)")?[^>]*>(.+?)<\/_\2>/sg) {
         $_ = $4;
+        s/\\/\\\\/g;
         if (!defined($3) || $3 ne "preserve") {
             s/\s+/ /g;
             s/^ //;

It'd be best if you report a bug about this so I don't forget about
it.

Cheers,
Danilo

PS. There's a new intltool list over at FreeDesktop.org, this one is
no longer used




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]