[XML-SIG] Specializing DOM exceptions
Martin v. Loewis
martin@loewis.home.cs.tu-berlin.de
Sun, 26 Nov 2000 20:13:55 +0100
> > I'd like to use gettext if available, so that somebody may actually
> > consider translating the messages - or drop the idea of translating
> > the __str__ representation of a DOM exception.
>
> I'm unclear here. Is it really so difficult to add a de_DE.py (or whatever)
> for translating the error strings?
That's not really difficult - although the tool support for
translating messages from .po files is better than that for .py files.
What *is* difficult is the selection code. For example, I have a LANG
setting of de_DE.UTF-8; I'd still like to get the de_DE
messages. Also, people that use de_AT.ISO-8859-1 still want the de_DE
catalog, since likely nobody will offer one specialized for Austria.
> When I put in the i18n hooks, I thought about gettext, but it's not
> available in a straightforward manner for Windows and some UNIX
> systems.
With Python 2.0, it is available uniformly on every system. On Python
1.5, it would fall back to the English catalog, ie.
try:
import gettext
bindtextdomain("pyxml",path-to-catalog)
def _(msg):
gettext.dgettext("pyxml",msg)
except ImportError:
def _(msg):
return msg
> Also, does distutils provide any support for gettext database
> pre-processing?
Not yet; this is part of the open issue of installing the Tools code
on every system (in this case, of msgfmt.py).
I think it would be possible to introduce another command build_mo or
so. I'll try to have it generate mo files with available tools, and
install the catalog into
_xmlplus/messages/<lang>/LC_MESSAGES/pyxml.po, or <prefix>/share/locale.
Regards,
Martin