Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django translation reverse

Is it possible to get msgid from msgstr?

Suppose I have

msgid "Table"
msgstr "Tisch"

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

like image 708
Andrew Fount Avatar asked Sep 20 '25 05:09

Andrew Fount


1 Answers

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).

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.

like image 89
WhyNotHugo Avatar answered Sep 22 '25 18:09

WhyNotHugo