Django翻译反向 [英] Django translation reverse
问题描述
是否可以从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屋!