Start with http://flask.pocoo.org/snippets/4/ first .
Secondly, you need to save these "limited" values as integers or enumerations in the database, and then create a lookup table for all these enumerations in the code (as Babel knows about them):
i18n_val = {0: _('running'), ...} # Or multi-level dict with different categories: i18n_all = { 'activity': { 0: _('running'), ... 'foo': { 0: _('bar..'), ... } }
And accessing the translated string from the template is now simple, like:
{{ i18n_val[obj.activity] }} {{ i18n_all['activity'][obj.activity] }}
To make the i18n_val and i18n_all variables available for all templates, simply register them using context processors .
plaes source share