Python WTForms语言环境(翻译)
我正在使用Flask、SQLAlchemy、WTForms 2.1和WTForms Alchemy(Python 2.7.10)构建一个应用程序。 我想更改WTForms的区域设置以翻译默认消息(例如“电子邮件已存在”等)。但是,当我在Form类上设置“locales”时,会出现以下错误:Python WTForms语言环境(翻译),python,flask,wtforms,Python,Flask,Wtforms,我正在使用Flask、SQLAlchemy、WTForms 2.1和WTForms Alchemy(Python 2.7.10)构建一个应用程序。 我想更改WTForms的区域设置以翻译默认消息(例如“电子邮件已存在”等)。但是,当我在Form类上设置“locales”时,会出现以下错误: IOError: [Errno 2] No translation file found for domain: 'wtforms' 我的表格是: class UserForm(ModelForm):
IOError: [Errno 2] No translation file found for domain: 'wtforms'
我的表格是:
class UserForm(ModelForm):
class Meta:
model = User
locales = ('pt')
submit = SubmitField('Save')
用户模型为:
class User(db.Model):
__tablename__ = 'usuario'
id = db.Column(db.Integer, primary_key=True)
nome = db.Column(db.String(80), info={'label': u'Nome*:'}, nullable=False)
如何设置WTForms区域设置?我看到他们的区域设置文件夹中有许多语言。您尝试过-locales=['pt']吗?这是正确的答案!我不相信!多谢各位!你试过-locales=['pt']吗?这是正确的答案!我不相信!多谢各位!