# HG changeset patch # User pjenvey # Date 1190956585 0 # Node ID 2f6b2b06a428caa03a45dc6634d4e02981ea6c69 # Parent 4f48bc780538e7251692f7d8874b6543c59167ef fix catalogs' charset values not being recognized thanks Jose Galvez diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,7 @@ * Fixed time formatting for 12 am and 12 pm. * Fixed output encoding of the `pybabel --list-locales` command. * PO files are now written in binary mode on windows (ticket #61). + * Fixed catalogs' charset values not being recognized. Version 0.9 diff --git a/babel/messages/catalog.py b/babel/messages/catalog.py --- a/babel/messages/catalog.py +++ b/babel/messages/catalog.py @@ -289,7 +289,7 @@ def _set_mime_headers(self, headers): for name, value in headers: - if name == 'content-type': + if name.lower() == 'content-type': mimetype, params = parse_header(value) if 'charset' in params: self.charset = params['charset'].lower() diff --git a/babel/messages/tests/pofile.py b/babel/messages/tests/pofile.py --- a/babel/messages/tests/pofile.py +++ b/babel/messages/tests/pofile.py @@ -18,6 +18,7 @@ from babel.messages.catalog import Catalog, Message from babel.messages import pofile +from babel.util import FixedOffsetTimezone, LOCALTZ class ReadPoTestCase(unittest.TestCase): @@ -75,6 +76,41 @@ self.assertEqual(1, len(list(catalog))) self.assertEqual(False, list(catalog)[0].fuzzy) + def test_header_entry(self): + buf = StringIO(r'''\ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2007 THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , 2007. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: 3.15\n" +"Report-Msgid-Bugs-To: Fliegender Zirkus \n" +"POT-Creation-Date: 2007-09-27 11:19+0700\n" +"PO-Revision-Date: 2007-09-27 21:42-0700\n" +"Last-Translator: John \n" +"Language-Team: German Lang \n" +"Plural-Forms: nplurals=2; plural=(n != 1)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=iso-8859-2\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 1.0dev-r313\n" +''') + catalog = pofile.read_po(buf) + self.assertEqual(1, len(list(catalog))) + self.assertEqual(u'3.15', catalog.version) + self.assertEqual(u'Fliegender Zirkus ', + catalog.msgid_bugs_address) + self.assertEqual(datetime(2007, 9, 27, 11, 19, + tzinfo=FixedOffsetTimezone(7 * 60)), + catalog.creation_date) + self.assertEqual(u'John ', catalog.last_translator) + self.assertEqual(u'German Lang ', catalog.language_team) + self.assertEqual(u'iso-8859-2', catalog.charset) + self.assertEqual(True, list(catalog)[0].fuzzy) + def test_obsolete_message(self): buf = StringIO(r'''# This is an obsolete message #~ msgid "foo"