Ticket #3063: ugettext.2.diff
File ugettext.2.diff, 1.6 KB (added by , 18 years ago) |
---|
-
django/utils/translation/trans_real.py
244 244 This function will be patched into the builtins module to provide the _ 245 245 helper function. It will use the current thread as a discriminator to find 246 246 the translation object to use. If no current translation is activated, the 247 message will be run through the default translation object. 247 message will be run through the default translation object. Since the 248 translation objects operate in unicode, conversion from and to the default 249 encoding is done. 248 250 """ 251 from django.conf import settings 249 252 global _default, _active 250 253 t = _active.get(currentThread(), None) 254 umessage = message.decode(settings.DEFAULT_CHARSET) 255 # GNUTranslations.ugettext() is used instead of .gettext() since .gettext() 256 # returns either an encoded string or a unicode string depending on whether 257 # the msgid was found or not. .ugettext() always expects a unicode msgid 258 # and returns a unicode translation. 251 259 if t is not None: 252 return t. gettext(message)260 return t.ugettext(umessage).encode(settings.DEFAULT_CHARSET) 253 261 if _default is None: 254 262 from django.conf import settings 255 263 _default = translation(settings.LANGUAGE_CODE) 256 return _default. gettext(message)264 return _default.ugettext(umessage).encode(settings.DEFAULT_CHARSET) 257 265 258 266 def gettext_noop(message): 259 267 """