Flask-JSONlocale: flask-jsonlocale should support parameters
Flask-JSONLocale library is used to localize Flask-based apps. Its users include Watch Translations or Commons Mass Description.
Problem
Sometimes, a system message can contain a parameter - for instance, you might want to make a software say "You created your account before X months". The X can differ for each reason. For that reason, when calling the library to localize such messages, parameters will be passed separately - and the library will use the translation and place the values at correct places. In Python, Python formatting can be used for that purpose.
Proposed solution
Flask-JSONlocale should allow messages to be python-formatted strings. When using the library, you could declare message as You have your account for %(months)s
, and then call the get_message()
function as get_message('message-code', months=12)
, which would then render as You have your account for 12 months
.
Student is expected to provide a GitHub pull request against https://github.com/urbanecm/flask-jsonlocale.