I have this piece of code for translations:
translations = gettext.translation(
locale_language,
localedir="gui/locale",
languages=[locale_language]
)
translations.install()
Where locale_language can be "en" (source language (msgids)) or "es" (translated language (msgstrs))
I need to have en.mo and es.mo to switch languages correctly, but since the source language is English, en.mo is not filled. I have to do it this way to run previous code when language changes.
I was wondering if there is a better way to do this, i.e., without an empty en.mo (also above code would requiere an if checking if locale_language == "en", but that is not the problem).
There is a never ending discussion whether the
msgidshould be the actual English string, or rather a "key" which will need to be translated to English as to any other language: look for instance at this question. And of course if you use key strings theen.mofile needs to be complete just like any other.If however you want to use actual English strings as
msgids then you may simply avoid to install a translation for English, and perhaps define a dummy_()function likeThis way you won't need a
en.moat all.