Marking translatable strings

Barry A. Warsaw bwarsaw at cnri.reston.va.us
Mon Sep 20 20:37:39 EDT 1999


>>>>> "BH" == Bernhard Herzog <herzog at online.de> writes:

    BH> The second part can be tricky in some situations. To begin
    BH> with, I'd say that docstrings should not be translated
    BH> automagically when a module is imported for performance
    BH> reasons

Agreed.  About the only place that I use docstrings programmatically
is when I write a script's usage information in the module docstring
of the file.  I always include the following usage() function:

def usage(code, msg=''):
    print __doc__ % globals()
    if msg: print msg
    sys.exit(code)

So here, it's not hard to push __doc__ through the translator before
doing the substitution.

Other than that, as you mention, all the mythical tools that access
the other various docstrings should know how to translate them, and
would do that on access.  I'm less concerned about how that would work 
because presumably it wouldn't be encoded in the program itself.

-Barry




More information about the Python-list mailing list