Marking translatable strings

Darrell news at dorb.com
Tue Sep 21 19:05:12 EDT 1999


Our project hasn't gone though translation yet. My simple minded approach
for that day follows and constructive criticism is appreciated.

All messages are in a small number of dictionaries like so.

_msgs={\
'replaceNotValid':'10# Replace not valid in dtd-map-rules',\
'invalidAttrib':'40# Unknown or invalid attribute "$&(name)s" in
%(tagName)s',\
}

All printing uses dictionary formatting -->  %(name)s.
A first pass provides standard formatting for all messages and converts the
$& too %
Then a second pass allows the caller to fill in specific information at
those points where the $& was replaced with %. The dictionary approach
avoids the problem of parms changing order with translation.

Wish there was a dictionary formatter that wouldn't throw a keyError when it
was missing a value. Then I could avoid the $& kluge. Better yet accept an
error handler function. If the function isn't provided then throw the error.


--
--Darrell






More information about the Python-list mailing list