[Petal] Re: [MKDoc-dev] [BUG] I18NFool clobbers things with the same key

Bruno Postle bruno at mkdoc.com
Thu Oct 7 10:52:27 BST 2004


Not sure which list this should go to, but the I18NFool translation 
stuff is as much related to internationalising Petal templates as 
the current task of translating the MKDoc interface.

Attached, a patch that adds some suitable warnings when running 
i18nfool-extract.

I released I18NFool-0.3 yesterday with some accumulated bugfixes, I 
guess I could release again.

On Wed 06-Oct-2004 at 15:04 +0100, Chris Croome wrote:
>
> If you have something like this in the templates:
>
>  <p
>    i18n:translate="foo"
>  >Foo</p>
>
>  <p
>    i18n:translate="foo"
>  >Bar</p>
>
> Then rather than warning you that the first value of foo is going to be
> replaced with the second I18NFool just clobbers the first value...

Chris' test is here:

  http://lists.webarch.co.uk/pipermail/mkdoc-dev/2004-October/000059.html

-- 
Bruno
-------------- next part --------------
diff -Nbaur -x CVS I18NFool-0.3/lib/I18NFool/Extractor.pm /home/bruno/src/cvs/I18NFool/lib/I18NFool/Extractor.pm
--- I18NFool-0.3/lib/I18NFool/Extractor.pm	2004-10-06 12:21:34.000000000 +0100
+++ /home/bruno/src/cvs/I18NFool/lib/I18NFool/Extractor.pm	2004-10-07 10:29:48.000000000 +0100
@@ -83,10 +83,21 @@
 
             $translate_id || next;
             $Results->{$Domain} ||= {};
-            $Results->{$Domain}->{$translate_id} = Locale::PO->new (
+
+            my $existing_po = $Results->{$Domain}->{$translate_id};
+            my $new_po = Locale::PO->new (
                 -msgid  => $translate_id,
                 -msgstr => _canonicalize ( $tree->{$attribute_name} ) || '',
             );
+
+            if ($existing_po && ($existing_po->{msgstr} ne $new_po->{msgstr}))
+            {
+                print STDERR "String for '$translate_id' doesn't match:\n".
+                             "   old: $existing_po->{msgstr}\n".
+                             "   new: $new_po->{msgstr}\n"
+            }
+
+            $Results->{$Domain}->{$translate_id} = $new_po;
         }
     };
 
@@ -112,10 +123,21 @@
 
         $translate_id || next;
         $Results->{$Domain} ||= {};
-        $Results->{$Domain}->{$translate_id} = Locale::PO->new (
+
+        my $existing_po = $Results->{$Domain}->{$translate_id};
+        my $new_po = Locale::PO->new (
             -msgid  => $translate_id,
             -msgstr => _canonicalize ( _extract_content_string ($tree) ) || '',
         );
+
+        if ($existing_po && ($existing_po->{msgstr} ne $new_po->{msgstr}))
+        {
+            print STDERR "String for '$translate_id' doesn't match:\n".
+                         "   old: $existing_po->{msgstr}\n".
+                         "   new: $new_po->{msgstr}\n"
+        }
+
+        $Results->{$Domain}->{$translate_id} = $new_po;
     };
 
     # I know, I know, the I18N namespace processing is a bit broken...


More information about the Petal mailing list