From: Armin Ronacher Date: Sun, 7 Jul 2013 18:09:23 +0000 (+0200) Subject: Added explicit charset argument to read_po and added changelog entries X-Git-Tag: 1.0~64 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=93b149cd2bc091f62cb98665ecd195f6b10571c4;p=thirdparty%2Fbabel.git Added explicit charset argument to read_po and added changelog entries --- diff --git a/ChangeLog b/ChangeLog index 204b2491..9c1b1330 100644 --- a/ChangeLog +++ b/ChangeLog @@ -66,6 +66,8 @@ http://svn.edgewall.org/repos/babel/tags/1.0.0/ pattern for currencies that includes the full name. * depend on pytz now and wrap it nicer. This gives us improved support for things like timezone transitions and an overall nicer API. + * Added support for explicit charset to PO file reading. + * Added experimental Python 3 support. Version 0.9.6 diff --git a/babel/messages/catalog.py b/babel/messages/catalog.py index 120469fd..3d90cf62 100644 --- a/babel/messages/catalog.py +++ b/babel/messages/catalog.py @@ -225,7 +225,7 @@ class Catalog(object): project=None, version=None, copyright_holder=None, msgid_bugs_address=None, creation_date=None, revision_date=None, last_translator=None, language_team=None, - charset='utf-8', fuzzy=True): + charset=None, fuzzy=True): """Initialize the catalog object. :param locale: the locale identifier or `Locale` object, or `None` @@ -243,7 +243,7 @@ class Catalog(object): :param revision_date: the date the catalog was revised :param last_translator: the name and email of the last translator :param language_team: the name and email of the language team - :param charset: the encoding to use in the output + :param charset: the encoding to use in the output (defaults to utf-8) :param fuzzy: the fuzzy bit on the catalog header """ self.domain = domain #: The message domain diff --git a/babel/messages/pofile.py b/babel/messages/pofile.py index c65dcf06..e8bb01ba 100644 --- a/babel/messages/pofile.py +++ b/babel/messages/pofile.py @@ -83,7 +83,7 @@ def denormalize(string): else: return unescape(string) -def read_po(fileobj, locale=None, domain=None, ignore_obsolete=False): +def read_po(fileobj, locale=None, domain=None, ignore_obsolete=False, charset=None): """Read messages from a ``gettext`` PO (portable object) file from the given file-like object and return a `Catalog`. @@ -118,16 +118,20 @@ def read_po(fileobj, locale=None, domain=None, ignore_obsolete=False): ([(u'main.py', 3)], set([])) ([u'A user comment'], [u'An auto comment']) + .. versionadded:: 1.0 + Added support for explicit charset argument. + :param fileobj: the file-like object to read the PO file from :param locale: the locale identifier or `Locale` object, or `None` if the catalog is not bound to a locale (which basically means it's a template) :param domain: the message domain :param ignore_obsolete: whether to ignore obsolete messages in the input + :param charset: the character set of the catalog. :return: a catalog object representing the parsed PO file :rtype: `Catalog` """ - catalog = Catalog(locale=locale, domain=domain) + catalog = Catalog(locale=locale, domain=domain, charset=charset) counter = [0] offset = [0]