From 74774969448928038293d03e4b583a2347e444cb Mon Sep 17 00:00:00 2001
From: Denis Barbier <bouzim@gmail.com>
Date: Sat, 5 Jan 2013 10:30:23 +0100
Subject: [PATCH] Ini: Include key parameter as an automatic comment

Based on a report and patch by Didier Raboud, thanks.
See http://bugs.debian.org/696992
---
 lib/Locale/Po4a/Ini.pm |   13 +++++--------
 t/data-26/test1.po     |    3 +++
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/lib/Locale/Po4a/Ini.pm b/lib/Locale/Po4a/Ini.pm
index 5bf51d9..e622ec7 100644
--- a/lib/Locale/Po4a/Ini.pm
+++ b/lib/Locale/Po4a/Ini.pm
@@ -43,26 +43,23 @@ sub parse {
         if ($line =~ /\"/) {
             print STDERR  "Start of line containing \".\n" if $debug;
             # Text before the first quote
-            $line =~ m/(^[^"\r\n]*")/;
+            $line =~ m/(^[^"\r\n]*)"/;
             my $pre_text = $1;
             print STDERR  "  PreText=".$pre_text."\n" if $debug;
             # The text for translation
-            $line =~ m/("[^\r\n]*")/;
+            $line =~ m/"([^\r\n]*)"/;
             my $quoted_text = $1;
             print STDERR  "  QuotedText=".$quoted_text."\n" if $debug;
             # Text after last quote
-            $line =~ m/("[^"\n]*$)/;
+            $line =~ m/"([^"\n]*$)/;
             my $post_text = $1;
             print STDERR  "  PostText=".$post_text."\n" if $debug;
-            # Remove starting and ending quotes from the translation text, if any
-            $quoted_text =~ s/^"//g;
-            $quoted_text =~ s/"$//g;
             # Translate the string it
-            $par = $self->translate($quoted_text, $ref);
+            $par = $self->translate($quoted_text, $ref, $pre_text);
             # Escape the \n characters
             $par =~ s/\n/\\n/g;
             # Now push the result
-            $self->pushline($pre_text.$par.$post_text."\n");
+            $self->pushline($pre_text.'"'.$par.'"'.$post_text."\n");
             print STDERR  "End of line containing \".\n" if $debug;
         }
         else
diff --git a/t/data-26/test1.po b/t/data-26/test1.po
index c45534c..30fbd7b 100644
--- a/t/data-26/test1.po
+++ b/t/data-26/test1.po
@@ -15,16 +15,19 @@ msgstr ""
 "Content-Type: text/plain; charset=CHARSET\n"
 "Content-Transfer-Encoding: ENCODING"
 
+#. type: key1=
 #: ../data-26/test1.ini:2
 #, no-wrap
 msgid "some value"
 msgstr ""
 
+#. type: key2=
 #: ../data-26/test1.ini:3
 #, no-wrap
 msgid "some other value"
 msgstr ""
 
+#. type: key4=
 #: ../data-26/test1.ini:5
 #, no-wrap
 msgid "toto\\ttata\\ntutu"
-- 
1.7.10.4

