translating strings from database flask-babel

后端 未结 2 957
予麋鹿
予麋鹿 2021-01-05 06:28

I\'m using Flask-Babel for translating string.

In some templates I\'m reading the strings from the database(postgresql). How can I translate the strings from the da

2条回答
  •  旧时难觅i
    2021-01-05 06:57

    It's not possible to use Babel in database translations, as database content is dynamic and babel translations are static (they didn't change).

    If you read the strings from the database you must save the translations on the database. You can create a translation table, something like (locale, source, destination), and get the translated values with a query.

提交回复
热议问题