Perhaps this answer is WAY too late, but I just found this, and I think it can help you.
import gettext t = gettext.translation('test', "./locale", languages=['fr']) _ = t.gettext print _("Hello world")
In my own program, I did it as follows:
import gettext DIR = "lang" APP = "ToolName" gettext.textdomain(APP) gettext.bindtextdomain(APP, DIR) #gettext.bind_textdomain_codeset("default", 'UTF-8') # Not necessary locale.setlocale(locale.LC_ALL, "") LANG = "FR_fr" lang = gettext.translation(APP, DIR, languages=[LANG], fallback = True) _ = lang.gettext
Note
My program has a lang directory. For each language, a directory is created in lang: * XX_xx * ( en_US ) Inside the en_US directory there is LC_MESSAGES , and inside there is TOOLNAME.mo
But this is my way of cross-language.
source share