I'm using python, gettext
and kivy
to make a multi-language app.
I have a label with some text Label(text = _("hi"))
. I made the code to be able to switch language, but that requires to reset the text, Label.text = _(Label.text)
, but this code is a problem, since once the translation is done, the text to be used as msgid
is translated, and therefore, not found in .po
files the next time.
I created a workaround, something like MyLabel(textKey = msgid)
. This solves all the problems, since changing language is done with MyLabel.text = _(MyLabel.textKey)
.
But this approach has an issue, if I use xgettext
to generate the .pot
file, msgid
is not recognized because it is not written as _(msgid)
and it cannot be (point 1).
My question is: is there a way to tell xgettext
to recognise textKey = msgid
?
I ended up using pygettext
, there I can use the -k
argument. See docs.