def translation_activate_block(function=None, language=None):
def _translation_activate_block(function):<EOL><INDENT>def _decorator(*args, **kwargs):<EOL><INDENT>tmp_language = translation.get_language()<EOL>try:<EOL><INDENT>translation.activate(language or settings.LANGUAGE_CODE)<EOL>return function(*args, **kwargs)<EOL><DEDENT>finally:<EOL><INDENT>translation.activate(tmp_language)<EOL><DEDENT><DEDENT>return wraps(function)(_decorator)<EOL><DEDENT>if function:<EOL><INDENT>return _translation_activate_block(function)<EOL><DEDENT>else:<EOL><INDENT>return _translation_activate_block<EOL><DEDENT>
Activate language only for one method or function