a work around for babel key error
When working on this repo, I tried to use flask-babel like this:
1 | from flask.ext.babel import gettext, ngettext |
It began complaining to me with “key error: babel” when I test it. I tried these things, don’t work:
- reinstall babel
- virtualenv a fresh venv and install the package
- I google it, one guy had a similar bug befor when using Flask-WTF with Flask-Babel
Finally I come up with a simple solution, and it work well for the time being. I use string format like this
1 | u'%d %s ago' % (period, plural) |
plus ‘if’ contrl statments instead of ‘ngettext’.