summaryrefslogtreecommitdiff
path: root/babel/messages/__init__.py
diff options
context:
space:
mode:
authorChristopher Lenz <cmlenz@gmail.com>2007-06-08 11:44:28 +0000
committerChristopher Lenz <cmlenz@gmail.com>2007-06-08 11:44:28 +0000
commit6d1cea7a91cc84e51a54bdbb03a74debb3544f5d (patch)
tree53db2848f4be611acca1d59bc2f5fc9ac2602f9e /babel/messages/__init__.py
parent00b5ed422c7d6d33208382e04ba4ceeefc0901e4 (diff)
downloadbabel-6d1cea7a91cc84e51a54bdbb03a74debb3544f5d.tar.gz
Fix typo in [58].
Diffstat (limited to 'babel/messages/__init__.py')
-rw-r--r--babel/messages/__init__.py61
1 files changed, 1 insertions, 60 deletions
diff --git a/babel/messages/__init__.py b/babel/messages/__init__.py
index 50583a1..283e1f8 100644
--- a/babel/messages/__init__.py
+++ b/babel/messages/__init__.py
@@ -13,63 +13,4 @@
"""Support for ``gettext`` message catalogs."""
-import gettext
-
-__all__ = ['Translations']
-__docformat__ = 'restructuredtext en'
-
-DEFAULT_DOMAIN = 'messages'
-
-
-class Translations(gettext.GNUTranslations):
- """An extended translation catalog class."""
-
- def __init__(self, fileobj=None):
- """Initialize the translations catalog.
-
- :param fileobj: the file-like object the translation should be read
- from
- """
- gettext.GNUTranslations.__init__(self, fp=fileobj)
- self.files = [getattr(fileobj, 'name')]
-
- def load(cls, dirname=None, locales=None, domain=DEFAULT_DOMAIN):
- """Load translations from the given directory.
-
- :param dirname: the directory containing the ``MO`` files
- :param locales: the list of locales in order of preference (items in
- this list can be either `Locale` objects or locale
- strings)
- :param domain: the message domain
- :return: the loaded catalog, or a ``NullTranslations`` instance if no
- matching translations were found
- :rtype: `Translations`
- """
- if not isinstance(locales, (list, tuple)):
- locales = [locales]
- locales = [str(locale) for locale in locales]
- filename = gettext.find(domain, dirname, locales)
- if not filename:
- return gettext.NullTranslations()
- return cls(fileobj=open(filename, 'rb'))
- load = classmethod(load)
-
- def merge(self, translations):
- """Merge the given translations into the catalog.
-
- Message translations in the specfied catalog override any messages with
- the same identifier in the existing catalog.
-
- :param translations: the `Translations` instance with the messages to
- merge
- :return: the `Translations` instance (``self``) so that `merge` calls
- can be easily chained
- :rtype: `Translations`
- """
- if isinstance(translations, Translations):
- self._catalog.update(translations._catalog)
- self.files.extend(translations.files)
- return self
-
- def __repr__(self):
- return "<%s %r>" % (type(self).__name__)
+from babel.messages.catalog import *