How to make flask extensions support i18n? Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of How to make flask extensions support i18n? without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I am developing a app which using flask and some extensions like flask-peewee, flask-wtf, etc.. The problem is, I want to translate strings in these extensions into Chinese, how to modify these extensions to support i18n?

I know flask-babel can make app support i18n, but it didn’t support i18n of other modules, especially extensions of flask.

And I don’t want to directly change strings in these modules, because it’s a dirty way.

Can any body help me?

Answer

Flask-wtf form already support i18n, it supported by default next locales https://github.com/wtforms/wtforms/tree/master/wtforms/locale, and you always can add missing.

I don’t find any information about peewee i18n support, but I also don’t found any language specific messages there.

For wftpeewee I found only support gettext usage in code without translation files, so you can just try translate this few strings in main application or update wtforms translation files.

For flask-peewee I don’t find any support in code and templates, so look like you will fix this yourself.

We are here to answer your question about How to make flask extensions support i18n? - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji