Mercurial > babel > mirror
changeset 595:57a08cc52623 trunk
don't use class-level variable as default value for method parameters in babel.support.Translations to ease custom inheritance (see #276, initial patch by Christopher A. Stelma)
author | fschwarz |
---|---|
date | Fri, 10 Aug 2012 20:41:22 +0000 |
parents | 5ba68e40d1d0 |
children | f63a07d648b6 |
files | babel/support.py |
diffstat | 1 files changed, 6 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/babel/support.py +++ b/babel/support.py @@ -287,26 +287,29 @@ DEFAULT_DOMAIN = 'messages' - def __init__(self, fileobj=None, domain=DEFAULT_DOMAIN): + def __init__(self, fileobj=None, domain=None): """Initialize the translations catalog. :param fileobj: the file-like object the translation should be read from + :param domain: the message domain (default: 'messages') """ + if domain is None: + domain = self.DEFAULT_DOMAIN gettext.GNUTranslations.__init__(self, fp=fileobj) self.files = filter(None, [getattr(fileobj, 'name', None)]) self.domain = domain self._domains = {} @classmethod - def load(cls, dirname=None, locales=None, domain=DEFAULT_DOMAIN): + def load(cls, dirname=None, locales=None, domain=None): """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 + :param domain: the message domain (default: 'messages') :return: the loaded catalog, or a ``NullTranslations`` instance if no matching translations were found :rtype: `Translations`