Opened 9 years ago

Closed 9 years ago

#26050 closed Bug (duplicate)

translation.activate does not report failure

Reported by: Michal Čihař Owned by: nobody
Component: Internationalization Version: 1.9
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Since fix for #25915 (f0a4ff2b118cbc3b7f9ac28a7d9e355288b546c0 in 1.9 branch), the translation.activate can bring translations in non working state, but doesn't report any failure. In past it has silently fallen back to default locale in this case, making the system work, but now it just quite unfriendly and hard to debug error from any gettext call.

Simple test case:

>>> from django.utils import translation
>>> translation.activate('foo')
>>> translation.gettext('x')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/django/utils/translation/__init__.py", line 77, in gettext
    return _trans.gettext(message)
  File "/usr/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 312, in gettext
    return do_translate(message, 'gettext')
  File "/usr/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 298, in do_translate
    result = getattr(translation_object, translation_function)(eol_message)
  File "/usr/lib/python2.7/gettext.py", line 348, in gettext
    tmsg = self._catalog.get(message, missing)
AttributeError: 'NoneType' object has no attribute 'get'

I think that either translation.activate should fail or fallback to default locale.

Change History (2)

comment:1 by Michal Čihař, 9 years ago

Just for the reference, testcase executed in Django 1.9:

>>> from django.utils import translation
>>> translation.activate('foo')
>>> translation.gettext('x')
'x'

comment:2 by Claude Paroz, 9 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #26046.

Note: See TracTickets for help on using tickets.
Back to Top