Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#23323 closed New feature (fixed)

Allow the use of translation.override as a decorator

Reported by: Thomas Chaumeny Owned by: nobody
Component: Translations Version: master
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 Changed 2 years ago by Thomas Chaumeny

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

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

comment:2 Changed 2 years ago by Simon Charette

Cc: Simon Charette added
Triage Stage: UnreviewedAccepted

comment:3 Changed 2 years ago by Simon Charette

Triage Stage: AcceptedReady for checkin

Will commit after a final review.

comment:4 Changed 2 years ago by Simon Charette <charette.s@…>

Resolution: fixed
Status: newclosed

In 2db1ed1033c0f542b3ffcbbb970d1b4dc881900f:

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

comment:5 Changed 2 years ago by Simon Charette <charette.s@…>

In 4926c0afe3ff8f306f752b9ae45366cc8fd3e42c:

Documented translation.override as a decorator.

refs #23323.

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