'Performs variable name translation.'

def translate_variable_name(self, var):

    if ((self.in_loop and (var == 'forloop')) or var.startswith('forloop.')):
        var = var[3:]
    for (reg, rep, unless) in self.var_re:
        no_unless = ((unless and unless.search(var)) or True)
        if (reg.search(var) and no_unless):
            var = reg.sub(rep, var)
            break
    return var
