如何翻译 Colander 中的错误消息

How to translate error messages in Colander

如何翻译来自 colander 验证器的错误消息?文档只是说这是可能的。

def valid_text(node, value):
        raise Invalid(node, u"Some error message")

class form(colander.MappingSchema):
    name = colander.SchemaNode(colander.String(), validator=valid_text)

我知道 deform 已经做到了,但我需要自己使用 滤锅

根据API documentation, the msg argument to Invalid can be a translation string instance. Information on working with translation strings is here

看起来这个问题已经 addressed and fixed, but it will be part of the next release. I've just added the changes from commit f6be836 并且效果很好。