diff options
author | Georg Brandl <georg@python.org> | 2010-05-27 00:06:48 +0200 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2010-05-27 00:06:48 +0200 |
commit | b3524a8697efdda99fef616f1c6525f37f27dfdb (patch) | |
tree | 7b6e57b1090c575bc3c961ef222fc3bf6fea864a | |
parent | 0d4c3a31b63e58602e469e65a164ddcfc1e4443e (diff) | |
download | sphinx-git-b3524a8697efdda99fef616f1c6525f37f27dfdb.tar.gz |
#427: fix the encode() method of translation proxies.
-rw-r--r-- | sphinx/locale/__init__.py | 12 | ||||
-rw-r--r-- | sphinx/search.py | 4 |
2 files changed, 14 insertions, 2 deletions
diff --git a/sphinx/locale/__init__.py b/sphinx/locale/__init__.py index 2165e7dd2..b0b89720c 100644 --- a/sphinx/locale/__init__.py +++ b/sphinx/locale/__init__.py @@ -41,6 +41,18 @@ class _TranslationProxy(UserString.UserString, object): data = property(lambda x: x._func(*x._args)) + # replace function from UserString; it instantiates a self.__class__ + # for the encoding result + + def encode(self, encoding=None, errors=None): + if encoding: + if errors: + return self.data.encode(encoding, errors) + else: + return self.data.encode(encoding) + else: + return self.data.encode() + def __contains__(self, key): return key in self.data diff --git a/sphinx/search.py b/sphinx/search.py index 0d07fd72f..729b63b2a 100644 --- a/sphinx/search.py +++ b/sphinx/search.py @@ -170,8 +170,8 @@ class IndexBuilder(object): otypes[domainname, type] = i otype = domain.object_types.get(type) if otype: - # use str() to fire translation proxies - onames[i] = str(domain.get_type_name(otype)) + # use unicode() to fire translation proxies + onames[i] = unicode(domain.get_type_name(otype)) else: onames[i] = type pdict[name] = (fn2index[docname], i, prio) |