import web


def i18n(function):
    def new_f(*args, **kwargs):
        function.func_globals['_'] = web.ctx.gettext
        function.func_globals['_n'] = web.ctx.ngettext
        return function(*args, **kwargs)
    return new_f


def pi18n(function):
    def new_f(*args, **kwargs):
        function.func_globals['_'] = web.ctx.plugin_gettext
        function.func_globals['_n'] = web.ctx.plugin_ngettext
        return function(*args, **kwargs)
    return new_f
