__getitem__(self,
id)
Return the message with the specified ID.
__setitem__(self,
id,
message)
Add or update the message with the specified ID.
add(self,
id,
string=None,
locations=(),
flags=(),
auto_comments=(),
user_comments=(),
previous_id=(),
lineno=None)
Add or update the message with the specified ID.
iterator
check(self)
Run various validation checks on the translations in the catalog.
update(self,
template,
no_fuzzy_matching=False)
Update the catalog based on the given template catalog.
This method simply constructs a Message object with the given
arguments and invokes __setitem__ with that object.
Parameters:
id - the message ID, or a (singular, plural) tuple for
pluralizable messages
string - the translated message string, or a
(singular, plural) tuple for pluralizable messages
locations - a sequence of (filenname, lineno) tuples
flags - a set or sequence of flags
auto_comments - a sequence of automatic comments
user_comments - a sequence of user comments
previous_id - the previous message ID, or a (singular, plural)
tuple for pluralizable messages
lineno - the line number on which the msgid line was found in the
PO file, if any
check(self)
Run various validation checks on the translations in the catalog.
For every message which fails validation, this method yield a
(message, errors) tuple, where message is the Message object
and errors is a sequence of TranslationError objects.
Returns: iterator
update(self,
template,
no_fuzzy_matching=False)
Update the catalog based on the given template catalog.
template - the reference catalog, usually read from a POT file
no_fuzzy_matching - whether to use fuzzy matching of message IDs
Property Details
header_comment
The header comment for the catalog.
>>> catalog = Catalog(project='Foobar', version='1.0',
... copyright_holder='Foo Company')
>>> print catalog.header_comment #doctest: +ELLIPSIS# Translations template for Foobar.# Copyright (C) ... Foo Company# This file is distributed under the same license as the Foobar project.# FIRST AUTHOR <EMAIL@ADDRESS>, ....#
The header can also be set from a string. Any known upper-case variables
will be replaced when the header is retrieved again:
>>> catalog = Catalog(project='Foobar', version='1.0',
... copyright_holder='Foo Company')
>>> catalog.header_comment = '''\... # The POT for my really cool PROJECT project.... # Copyright (C) 1990-2003 ORGANIZATION... # This file is distributed under the same license as the PROJECT... # project.... #'''>>> print catalog.header_comment
# The POT for my really cool Foobar project.# Copyright (C) 1990-2003 Foo Company# This file is distributed under the same license as the Foobar# project.#
The MIME headers of the catalog, used for the special msgid "" entry.
The behavior of this property changes slightly depending on whether a locale
is set or not, the latter indicating that the catalog is actually a template
for actual translations.
Here's an example of the output for such a catalog template:
>>> created = datetime(1990, 4, 1, 15, 30, tzinfo=UTC)
>>> catalog = Catalog(project='Foobar', version='1.0',
... creation_date=created)
>>> for name, value in catalog.mime_headers:
... print'%s: %s' % (name, value)
Project-Id-Version: Foobar 1.0Report-Msgid-Bugs-To: EMAIL@ADDRESSPOT-Creation-Date: 1990-04-01 15:30+0000PO-Revision-Date: YEAR-MO-DA HO:MI+ZONELast-Translator: FULL NAME <EMAIL@ADDRESS>Language-Team: LANGUAGE <LL@li.org>MIME-Version: 1.0Content-Type: text/plain; charset=utf-8Content-Transfer-Encoding: 8bitGenerated-By: Babel ...
And here's an example of the output when the locale is set:
>>> revised = datetime(1990, 8, 3, 12, 0, tzinfo=UTC)
>>> catalog = Catalog(locale='de_DE', project='Foobar', version='1.0',
... creation_date=created, revision_date=revised,
... last_translator='John Doe <jd@example.com>',
... language_team='de_DE <de@example.com>')
>>> for name, value in catalog.mime_headers:
... print'%s: %s' % (name, value)
Project-Id-Version: Foobar 1.0Report-Msgid-Bugs-To: EMAIL@ADDRESSPOT-Creation-Date: 1990-04-01 15:30+0000PO-Revision-Date: 1990-08-03 12:00+0000Last-Translator: John Doe <jd@example.com>Language-Team: de_DE <de@example.com>Plural-Forms: nplurals=2; plural=(n != 1)MIME-Version: 1.0Content-Type: text/plain; charset=utf-8Content-Transfer-Encoding: 8bitGenerated-By: Babel ...