Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#23323 closed New feature (fixed)

Allow the use of translation.override as a decorator

Reported by: Thomas C Owned by: nobody
Component: Translations Version: dev
Severity: Normal Keywords:
Cc: Simon Charette 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

I think it would be nice if translation.override could be used as a decorator.

Although a comment in https://code.djangoproject.com/ticket/16690#comment:2 suggested this was not useful, I have experienced several cases where it is. For instance, I have some functions which are sending mail and I want those mails to be translated in some default language which is not the one of the user doing the action. Having the function decorated is better in terms of readability than a long with statement which introduces heavy indentation.

Change History (5)

comment:1 by Thomas C, 10 years ago

Here is my pull request for this feature: https://github.com/django/django/pull/3088

comment:2 by Simon Charette, 10 years ago

Cc: Simon Charette added
Triage Stage: UnreviewedAccepted

comment:3 by Simon Charette, 10 years ago

Triage Stage: AcceptedReady for checkin

Will commit after a final review.

comment:4 by Simon Charette <charette.s@…>, 10 years ago

Resolution: fixed
Status: newclosed

In 2db1ed1033c0f542b3ffcbbb970d1b4dc881900f:

Fixed #23323 -- Made django.utils.translation.override usable as a decorator.

comment:5 by Simon Charette <charette.s@…>, 10 years ago

In 4926c0afe3ff8f306f752b9ae45366cc8fd3e42c:

Documented translation.override as a decorator.

refs #23323.

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