read_po(fileobj,
locale={ ' territory_zones ' : { ' 001 ' : [ ' Etc/GMT ' , ' Etc/GMT-1 ' , ' Etc/GMT- ... ,
domain={ ' territory_zones ' : { ' 001 ' : [ ' Etc/GMT ' , ' Etc/GMT-1 ' , ' Etc/GMT- ... ,
ignore_obsolete=True)
|
|
Read messages from a gettext PO (portable object) file from the given
file-like object and return a Catalog.
>>> from StringIO import StringIO
>>> buf = StringIO('''
... #: main.py:1
... #, fuzzy, python-format
... msgid "foo %(name)s"
... msgstr ""
...
... # A user comment
... #. An auto comment
... #: main.py:3
... msgid "bar"
... msgid_plural "baz"
... msgstr[0] ""
... msgstr[1] ""
... ''')
>>> catalog = read_po(buf)
>>> catalog.revision_date = datetime(2007, 04, 01)
>>> for message in catalog:
... if message.id:
... print (message.id, message.string)
... print ' ', (message.locations, message.flags)
... print ' ', (message.user_comments, message.auto_comments)
(u'foo %(name)s', '')
([(u'main.py', 1)], set([u'fuzzy', u'python-format']))
([], [])
((u'bar', u'baz'), ('', ''))
([(u'main.py', 3)], set([]))
([u'A user comment'], [u'An auto comment'])
- Parameters:
fileobj - the file-like object to read the PO file from
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)
domain - the message domain
ignore_obsolete - whether to ignore obsolete messages in the input
- Returns: iterator
- an iterator over (message, translation, location) tuples
|