Search code examples
internationalizationwxwidgetsgettext

gettext: How to fall back to the base language?


I am planning to rewrite our application using wxWidgets. Also because of that I would like to use the gettext way of working with human languages. We currently use four of them: Czech, Slovak, English, and German. The specific languages are not that important.

What is important, the Czech and English are considered a kind of base languages. This means that if the use switches to German, and the text is not defined there, he or she automatically gets the English text (no problem with gettext here). However, when the user uses Slovak, then the fallback language is Czech. And when the user uses English it can even fall back to Czech (a kind of bug by developers as English should also be complete).

I know that gettext uses one language as a default -- written directly in the sources. The other languages are supplied as .mo files. Being new to gettext and wxWidgets...

Is there any way to implement the fallback to another explicit language that differs from the default language (i.e. from source files)? In other words, can more languages be present in memory and switched dynamically?

Thanks for your time and experience,

Petr


Solution

  • No, you can't selectively provide such fallbacks. OTOH absolutely nothing prevents you from copying Czech translations to Slovak ones (i.e. cp cz.po sk.po) and then replacing only some of them with the real Slovak translations. And, of course, for German it should work automatically if you use English in your sources (and even if your native language is Czech, I strongly advise you to do this).