[Django] #26050: translation.activate does not report failure

6 views
Skip to first unread message

Django

unread,
Jan 7, 2016, 4:31:09 AM1/7/16
to django-...@googlegroups.com
#26050: translation.activate does not report failure
--------------------------------------+--------------------
Reporter: nijel | Owner: nobody
Type: Bug | Status: new
Component: Internationalization | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+--------------------
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/26050>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 7, 2016, 4:32:48 AM1/7/16
to django-...@googlegroups.com
#26050: translation.activate does not report failure
-------------------------------------+-------------------------------------

Reporter: nijel | Owner: nobody
Type: Bug | Status: new
Component: | Version: 1.9
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by nijel):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Just for the reference, testcase executed in Django 1.9:

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

'x'
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26050#comment:1>

Django

unread,
Jan 7, 2016, 1:20:18 PM1/7/16
to django-...@googlegroups.com
#26050: translation.activate does not report failure
-------------------------------------+-------------------------------------
Reporter: nijel | Owner: nobody
Type: Bug | Status: closed
Component: | Version: 1.9
Internationalization |
Severity: Normal | Resolution: duplicate
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by claudep):

* status: new => closed
* resolution: => duplicate


Comment:

Duplicate of #26046.

--
Ticket URL: <https://code.djangoproject.com/ticket/26050#comment:2>

Reply all
Reply to author
Forward
0 new messages