Marking translatable strings
François Pinard
pinard at IRO.UMontreal.CA
Tue Sep 28 22:16:30 EDT 1999
Greg Ewing <greg.ewing at compaq.com> writes:
> Tim Peters wrote:
> >
> > > Experience shows that horizontal space is often a valuable resource while
> > > writing code, so we should try to be economical there for overall
> > > legibility, much more than typability.
> How about hacking the unary "+" operator on strings to
> do translation? It would be hard to get any more horizontally
> economical than that, and it wouldn't require any change to
> the scanner or parser.
It would need a change to Python, as currently:
TypeError: bad operand type(s) for unary +
but indeed, if such a change was accepted, it would be especially neat.
For example:
"printing %s" % +"hello"
+"printing %s" % "hello"
+"printing %s" % +"hello"
would allow precise, yet unobtrusive control over exactly what gets
translated. I'm presuming, here, that unary `+' binds very tightly.
Would you foresee any difficulty while writing a _simple_ tool, to be
integrated in `xgettext' (or `xpot':-) that would properly identify unary
`+' operators before strings, I mean, never mistaking a binary `+' as unary?
--
François Pinard http://www.iro.umontreal.ca/~pinard
More information about the Python-list
mailing list