[Python-Dev] Re: [I18n-sig] Changes to gettext.py for Python 2.3 (original) (raw)

Barry Warsaw barry@python.org
11 Apr 2003 16:37:56 -0400


On Fri, 2003-04-11 at 15:54, "Martin v. L�wis" wrote:

To avoid breakage, you could define ugettext as

def ugettext(self, message): if isinstance(message, unicode): tmsg = self.catalog.get(message.encode(self.charset)) if tmsg is None: return message else: tmsg = self.catalog.get(message, message) return unicode(tmsg, self.charset)

I suppose we could cache the conversion to make the next lookup more efficient. Alternatively, if we always convert internally to Unicode we could encode on .gettext(). Then we could just pick One Way and do away with the coerce flag.

-Barry