]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Include patch from Asheesh Laroia. Fixes #45.
authorPedro Algarvio <pedro@algarvio.me>
Thu, 18 Dec 2008 00:19:47 +0000 (00:19 +0000)
committerPedro Algarvio <pedro@algarvio.me>
Thu, 18 Dec 2008 00:19:47 +0000 (00:19 +0000)
babel/messages/pofile.py
babel/messages/tests/pofile.py

index 98cd3f8db8f257d098999971855161f7aa905dba..83cc3080aa8f857dbc3e1721d01a41682ea8b150 100644 (file)
@@ -396,6 +396,9 @@ def write_po(fileobj, catalog, width=76, no_location=False, omit_header=False,
 
     def _write_message(message, prefix=''):
         if isinstance(message.id, (list, tuple)):
+            if message.context:
+                _write('%smsgctxt %s\n' % (prefix,
+                                           _normalize(message.context, prefix)))
             _write('%smsgid %s\n' % (prefix, _normalize(message.id[0], prefix)))
             _write('%smsgid_plural %s\n' % (
                 prefix, _normalize(message.id[1], prefix)
@@ -410,6 +413,9 @@ def write_po(fileobj, catalog, width=76, no_location=False, omit_header=False,
                     prefix, idx, _normalize(string, prefix)
                 ))
         else:
+            if message.context:
+                _write('%smsgctxt %s\n' % (prefix,
+                                           _normalize(message.context, prefix)))
             _write('%smsgid %s\n' % (prefix, _normalize(message.id, prefix)))
             _write('%smsgstr %s\n' % (
                 prefix, _normalize(message.string or '', prefix)
index 7e245760c873cf9319fd5954e32d19148ffd192d..8e85af975314dbdbaa80c73feab5bb69392bda14 100644 (file)
@@ -163,6 +163,12 @@ msgstr "Bahr"
         message = catalog.get('bar', context='Menu')
         self.assertEqual('Menu', message.context)
 
+        # And verify it pass through write_po
+        out_buf = StringIO()
+        pofile.write_po(out_buf, catalog, omit_header=True)
+        assert out_buf.getvalue().strip() == buf.getvalue().strip(), \
+                                                            out_buf.getvalue()
+
     def test_singlular_plural_form(self):
         buf = StringIO(r'''msgid "foo"
 msgid_plural "foo"