[Python-ideas] i18n and Python tracebacks
reingart at gmail.com
Sun Oct 28 08:30:00 CET 2012
On Tue, May 18, 2010 at 12:14 AM, Stephen J. Turnbull
<stephen at xemacs.org> wrote:
> Nick Coghlan writes:
> > It would actually be interesting to see just how far someone could get
> > [on translating tracebacks] purely with sys.excepthook.
> > It would be subject to some fairly significant limitations (particularly
> > when it comes to reparsing strings with interpolated values), but the
> > traceback parsing and comparison code in doctest may offer a good
> > starting point.
> Actually, it shouldn't be too hard to handle the interpolations. In
> fact the language to be parsed is probably mostly pretty simple, and
> can be automatically translated to BNF or whatever input your favorite
> parsing library wants from the .pot file. The generated grammar
> probably would be on the order of the size of the .pot file, no? It
> could be stored with the .mos as a "pseudo-translation".
Interpolation is not very hard (although it could be error prone).
I tried that with some regex but I'd found some dead-ends because some
messages are hard-coded at the interpreter level, so they cannot be
implemented purely with sys.excepthook
I'd created a parallel project just if anyone is interested (would be
the pure-python version but it would require too much work):
Maybe I missed something, but the gettext approach seems more
consistent and cleaner, and IMHO using gettext is easier than
rewriting an interpreter :-)
[sorry for the 2-year delay]
More information about the Python-ideas