﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
16690	Add translation.activate decorator/context manager	Ralph Broenink	nobody	"Currently, internationalization outside of templates and views requires several lines of code, identically each time:

{{{
from django.utils import translation
def welcome_translated(language):
    cur_language = translation.get_language()
    try:
        translation.activate(language)
        text = translation.ugettext('welcome')
    finally:
        translation.activate(cur_language)
    return text
}}}
(source: https://docs.djangoproject.com/en/dev/howto/i18n/)

However, this could easily be fitted within both decorators and context managers, allowing the following syntax:

{{{
@translation.activate(language)
def welcome_translated(language):
    return translation.ugettext('welcome')
}}}
or
{{{
def welcome_translated(language):
    with translation.activate(language):
        return translation.ugettext('welcome')
}}}

This would decrease the lines of code and the developer would not have to care for the case when the execution somehow fails and forgets to add the try/finally clause."	New feature	closed	Internationalization	1.3	Normal	worksforme			Unreviewed	0	0	0	0	0	0
