Django翻译反向 [英] Django translation reverse

查看:63
本文介绍了Django翻译反向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从msgstr获取msgid?

Is it possible to get msgid from msgstr?

假设我有

msgid "Table"
msgstr "Tisch"

如果使用的是德语,是否有任何功能可以执行inverse_ugettext('Tisch') -> Table?

If active language is German is there any function to execute inverse_ugettext('Tisch') -> Table?

推荐答案

不,这不可能简单.至少不能与django i18n实现(使用python的gettext)一起使用.

No, it's not trivially possible. At least not with the django i18n implementation (which uses python's gettext).

如果您真的需要此功能,则必须以某种方式手动实施(

If you really need this, you'll have to manually implement it somehow (the gettext source might be a useful starting place).

如果在这里速度不是很关键(例如,这是一个非常少见的操作),则您可能希望解析.po文件,该文件更容易解析,然后在其中查找相反的内容.

If speed is not critical here (eg: it's a very infrequent operation), you might want to parse the .po files, which are a lot simpler to parse, and find the reverse there.

这篇关于Django翻译反向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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