New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use the built-in translations provided by WTForms #303
Comments
Actually, I don't know too much about i18n. Install |
@greyli No. You must use Flask-Babel to enable i18n. |
Thanks! |
@lepture Sorry to disturb you, I thought maybe there is a misunderstanding. Actually, I just want to set the default error message's language to Chinese. How to do it without Flask-Babel or Babel just like use pure WTForms? Similar to this SO question. |
The working code with pure WTForms: class MyBaseForm(Form):
class Meta:
locales = ['zh']
class HelloForm(MyBaseForm):
name = StringField('Name', validators=[DataRequired()])
submit = SubmitField() Then the error message will be displayed in Chinese. |
@greyli The current implementation is using Babel to determine the language automatically. In this case, you will have to use Babel. |
Is it possible to add support for this usage? I thought it's a common need. Sometimes people don't want to add i18n/l10n support, the only thing they want is using the specific built-in translation. |
Just something like #300, but with a better implementation. |
If you think it's ok, I'll submit a PR. |
Sure, if it won’t take too much work. |
As describe in WTForms's documentation here, we can define a base class to set the default locale app-widely:
How to achieve this with Flask-WTF?
The text was updated successfully, but these errors were encountered: