python-babel / flask-babel

i18n and l10n support for Flask based on Babel and pytz
https://python-babel.github.io/flask-babel/
Other
432 stars 159 forks source link

Install `pgettext`, `npgettext` for Jinja templates #190

Closed homeworkprod closed 1 year ago

homeworkprod commented 2 years ago

This makes these callables (instead of None in both cases) available for use as functions in Jinja templates using Flask's/Jinja's own hook.

I took the liberty to turn the first two positional arguments into keyword arguments to align with the rest of the arguments and make it easier to understand what they refer to.

I also renamed the argument x to s (for "string") as used in the implementation of Domain.gettext to align it with the other anonymous functions' arguments' names.

homeworkprod commented 2 years ago

Oh my, the test on Python 3.5 fails because the new keyword arguments (introduced in https://github.com/pallets/jinja/pull/1126) require Jinja v3.x while

Sooo … @TkTech, do you plan to drop support for Python 3.5 (end of security fixes: 2020-09-30) by any chance? :)

homeworkprod commented 1 year ago

The Python 3.5 issue can be resolved with #211.

Not sure about requiring at least Jinja 3, though. Probably fair at this point (v3.0.0 was released on 2021-05-11), especially as existing releases of Flask-Babel are still available?

homeworkprod commented 1 year ago

Rebased onto master now that #211 has been merged.