diff --git a/babel/messages/catalog.py b/babel/messages/catalog.py index 065ef35fb..ce7d4bb04 100644 --- a/babel/messages/catalog.py +++ b/babel/messages/catalog.py @@ -180,8 +180,10 @@ def python_format(self): """Whether the message contains Python-style parameters. >>> Message('foo %(name)s bar').python_format + False + >>> Message('foo %(name)s bar', flags=['python-format']).python_format True - >>> Message(('foo %(name)s', 'foo %(name)s')).python_format + >>> Message(('foo %(name)s', 'foo %(name)s'), flags=['python-format']).python_format True :type: `bool`""" diff --git a/babel/messages/extract.py b/babel/messages/extract.py index 8f12f9330..6be3f477b 100644 --- a/babel/messages/extract.py +++ b/babel/messages/extract.py @@ -282,7 +282,7 @@ def extract(method, fileobj, keywords=DEFAULT_KEYWORDS, comment_tags=(), >>> from io import BytesIO >>> for message in extract('python', BytesIO(source)): ... print(message) - (3, u'Hello, world!', [], None) + (3, u'Hello, world!', [], None, set()) :param method: an extraction method (a callable), or a string specifying the extraction method (.e.g. "python"); diff --git a/babel/messages/pofile.py b/babel/messages/pofile.py index 3485a2ab6..c23a19308 100644 --- a/babel/messages/pofile.py +++ b/babel/messages/pofile.py @@ -475,7 +475,7 @@ def write_po(fileobj, catalog, width=76, no_location=False, omit_header=False, >>> catalog = Catalog() >>> catalog.add(u'foo %(name)s', locations=[('main.py', 1)], - ... flags=('fuzzy',)) + ... flags=('fuzzy', 'python-format')) >>> catalog.add((u'bar', u'baz'), locations=[('main.py', 3)]) diff --git a/tests/messages/data/project/i18n/fi_BUGGY/LC_MESSAGES/messages.po b/tests/messages/data/project/i18n/fi_BUGGY/LC_MESSAGES/messages.po index 0a0745b42..a7fbce54c 100644 --- a/tests/messages/data/project/i18n/fi_BUGGY/LC_MESSAGES/messages.po +++ b/tests/messages/data/project/i18n/fi_BUGGY/LC_MESSAGES/messages.po @@ -1,5 +1,6 @@ msgid "" msgstr "" +#, python-format msgid "bar %(sign)s" msgstr "tanko %(merkki)s" diff --git a/tests/messages/test_catalog.py b/tests/messages/test_catalog.py index 8f51e75be..7016c26fa 100644 --- a/tests/messages/test_catalog.py +++ b/tests/messages/test_catalog.py @@ -305,8 +305,10 @@ def test_message_pluralizable(): def test_message_python_format(): - assert catalog.Message('foo %(name)s bar').python_format - assert catalog.Message(('foo %(name)s', 'foo %(name)s')).python_format + assert catalog.Message('foo %(name)s bar', flags={'python-format'}).python_format + assert catalog.Message(('foo %(name)s', 'foo %(name)s'), flags={'python-format'}).python_format + assert not catalog.Message('foo %(name)s bar').python_format + assert not catalog.Message(('foo %(name)s', 'foo %(name)s')).python_format def test_catalog():