#25295 closed Bug (fixed)
translation.override() context manager doesn't return to deactivated state when there's no activated language
Reported by: | David Nelson Adamec | Owned by: | nobody |
---|---|---|---|
Component: | Internationalization | Version: | 1.8 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
From a shell, I'm able to do the following:
In [1]: from django.utils import translation In [2]: translation.get_language() In [3]: with translation.override('fr'): ...: pass ...: In [4]: translation.get_language() Out[4]: 'fr'
override usually reverts to the previous language upon leaving the context manager, so this behavior seems unexpected.
This is new in Django 1.8: before, get_language() returned the default language, so the default language would be activated after override finished. Now get_language() returns None when there is no active catalog, so override attempts to activate None, which has no effect.
Change History (6)
comment:1 by , 9 years ago
Description: | modified (diff) |
---|
comment:2 by , 9 years ago
Summary: | override context manager does not return to deactivated state → translation.override() context manager doesn't return to deactivated state when there's no activated language |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Bug |
comment:3 by , 9 years ago
Has patch: | set |
---|
comment:4 by , 9 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Seems like a candidate for backport if you like.
Note:
See TracTickets
for help on using tickets.
I'm not a translation expert, but that does seem incorrect.