从数据库烧瓶巴贝尔翻译字符串 [英] translating strings from database flask-babel
问题描述
在一些模板中,我从数据库中读取字符串(postgresql)。
如何使用Flask-Babel从数据库中翻译字符串?
数据库翻译,因为数据库内容是动态的,babel翻译是静态的(他们没有改变)。
如果您从数据库读取字符串,则必须将翻译保存在数据库中。你可以创建一个翻译表,类似(locale,source,destination),并用查询获得翻译后的值。
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 database using Flask-Babel?
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.
这篇关于从数据库烧瓶巴贝尔翻译字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!