从数据库烧瓶巴贝尔翻译字符串 [英] translating strings from database flask-babel

查看:198
本文介绍了从数据库烧瓶巴贝尔翻译字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆