gnumed-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnumed-devel] i18n and icons


From: Karsten Hilbert
Subject: Re: [Gnumed-devel] i18n and icons
Date: Tue, 17 Sep 2002 06:40:57 +0200
User-agent: Mutt/1.3.22.1i

Maybe a bit more explanation is in order:

Consider gmAllergies.py. The default icon is a capital letter
"A". While this is fine with many languages it may not be so
for, say, French where the customary label for allergies might
be "reaction allergique" (just a wild guess). Hence a capital
"R" would be in order.

Now, let's look at the icon data infrastructure that we have
in place. The "new style" is to have a dictionary __icons in
the plugin subclass. The keys are supposed to be strings which
can be applied to GetIconData() on plugin load according to
settings in a config repository or whatever. If an invalid key
is handed to GetIconData() it will fallback to a known good
key. The Right Way(TM) to handle l10n()ing of icons would be
to have nice unique strings as icon data keys (such as
"icon_capital_letter_A"). When falling back to the default
this key would need to be wrapped in _() to get automatic
l10n()ing. Same for hardcoded icon data keys elsewhere in the
code.

Code example:

#----------------------------------------------------------------------
class gmGP_Allergies (gmPlugin.wxPatientPlugin):
    """Plugin to encapsulate the allergies window"""
    
        __icons = {
"""icon_letter_A""": 
'x\xda\xd3\xc8)0\xe4\nV74S\x00"\x13\x05Cu\xae\xc4`\xf5|\x85d\x05e\x17W\x10\
\x04\xf3\xf5@|77\x03\x00\xf3\x15\x80|\xbf\xfc\xbcT0\'address@hidden
HPO\x0f\xab`\x04\x86\xa0\x9e\x1e\\)\xaa`\x04\x9aP$\x02\xa6\x14Y0\x1f\xa6\
\x14&\xa8\x07\x05h\x82\x11\x11 \xfd\x11H\x821\x84[\x11\x82Hn\x85i\x8f\x80\
\xba&"\x82\x08\xbf\x13\x16\xd4\x03\x00\xe4\xa2I\x9c'
}

    def GetIconData(self, anIconID=None):
        if anIconID == None:
            return self.__icons[0]
        else:
            if self.__icons.has_key(anIconID):
                return self.__icons[anIconID]
        else:
            return self.__icons[_("""icon_letter_A""")]
#----------------------------------------------------------------------

Note how the default return in GetIconData is wrapped in _().
Translators then need to provide the key of a locally
appropriate icon. If they don't translate the key gettext will
automatically fall back to the hardcoded key.

Pretty nice, actually.

Karsten
-- 
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346




reply via email to

[Prev in Thread] Current Thread [Next in Thread]