Skip to content Skip to sidebar Skip to footer

Gettext Fallbacks Don't Work With Untranslated Strings

In source code of my application I wrapped with gettext strings in russian, so this is my default language and *.po files based on it. Now I need to make fallbacks chain - string t

Solution 1:

Ok, python is doing something different from the standard fallback mechanism for added functionality which is not working like you think it should. This may warrant a bug report.

The standard fallback mechanism only has one fall back if a string is not in a translation: use the source string. In most cases this is english (the C or POSIX locale forces no lookups), but in your case because the messages in the source the C locale has russian text (which may cause other problems because sometimes the C locale assumes ascii not utf8). The current recommended best practice is to use english in the C locale encoded in seven bit ascii and then translate to all other languages. This is a significant redesign (and admittedly anglocentric) but unless someone improves the tools (which would be even more significant redesign) this is probably your best bet.

Solution 2:

Only way to solve it was removing untranslated strings while compiling *.mo files. Patch babel/messages/mofile.py write_mo with

messages = [m for m in messages if m.string]

Post a Comment for "Gettext Fallbacks Don't Work With Untranslated Strings"