Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python WTForms语言环境(翻译)_Python_Flask_Wtforms - Fatal编程技术网

Python WTForms语言环境(翻译)

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):

我正在使用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):
    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']吗?这是正确的答案!我不相信!多谢各位!