a work around for babel key error

When working on this repo, I tried to use flask-babel like this:

1
2
3
from flask.ext.babel import gettext, ngettext
gettext(mystring)
ngettext(singular, plural, period)

It began complaining to me with “key error: babel” when I test it. I tried these things, don’t work:

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’.