Translations, translations, translations

Dirk Hohndel dirk at
Sun Oct 21 11:44:20 PDT 2012

Ok, here's what I've got now (just pushed to master)... from the commit

    Fix the way we handle translated event names
    Here is what Linus reported:
     I think you have made a mistake in trying to translate some of
     Translating some of those things based on locale is *wrong*, because
     they are saved in the XML file.
     That covers at least the warnings: they'll get translated when you
     import them, and then saved to the XML file as that translation, but
     now if you start subsurface in another locale, they will not get
     translated back.
     So translating XML file contents is fundamentally buggy. It just
     shouldn't be done.
     So all the "translations" for the event handling are buggy, and
     generate crap. Please don't do that. Leave them as English.
    And of course he is absolutely right. However, instead of not translating
    them at all, this commit fixes things a better way - we now mark the
    strings for translation but store the original English strings everywhere
    (in the in-memory data structure as well as in the XML file). Only when we
    actually display something on the screen (in a tooltip or in the filter
    dialog) do we actually translate the strings into the native language.
    This should address both Linus' issue and the desire to have localized
    event texts.

Please take a look at the commit. I think it is remarkably straight
forward. We simply use the N_() macro instead of the _() macro.
N_() expands to simply it's argument, it's just used to mark a string
for translation. So we ensure that only the English names are stored.

Then in the two places we display event names on screen (tooltips for
the little triangles and in the event filter dialog) we translate the

This should be safe to do, this shouldn't change any of the translations
(except for line numbers - that's just such a noisy thing).

I believe this is the correct fix.


More information about the subsurface mailing list