[Edu-sig] Request advice/opinions on translations for Crunchy

Andre Roberge andre.roberge at gmail.com
Fri Aug 18 00:32:29 CEST 2006

On 8/17/06, Dan Crosta <dcrosta at sccs.swarthmore.edu> wrote:
> On Aug 17, 2006, at 4:49 PM, Andre Roberge wrote:
> > 4. [and this is what I'm mostly asking about]  Graphics commands, for
> > example circle() or set_line_color() or set_line_colour()  [we support
> > both syntax ;-)].  The strings are ready to be translated [i.e.
> > replace circle() by cercle(), or set_line_color() by
> > couleur_de_ligne()] but, since the documentation (and tutorials) are
> > likely to be only in English, I'm wondering about the wisdom of
> > translating them.
> Out of curiosity, how are you going to handle translating the api? Is
> there some functionality for this in python itself? Are you actually
> emulating method accesses with __getattr__()? Are you using some
> other tool to translate the method names (and presumably if you were,
> for readability you could translate variable names, comments, etc, as
> well) into actual internationalized source files?

I'll address the last question first.  I am not aware of *any* program
that has its source files translated.  Nor do I see any reason to ever
want to do so.  The source code (including comments) for Crunchy is
written in English and will remain as such.  This is the same for the
source code of the Python standard library.

A good reference (with links) for understanding translations for
computer programs is:

In what follows, I'll provide a "simplified" description....

First, some background. Crunchy is designed to deliver interactive
Python tutorials.  In order to make tutorials more interesting, some
basic graphics capabilities (shape drawing, function plotting, etc.)
have been built-in.  A simple graphics program might include things
circle( (100, 100), 30)
filled_circle( (200, 200), 50)
===  etc...
This program, when executed, produces a series of javascript commands
that are used to draw the corresponding shapes within an html
<canvas>.  The way this is done is that the
user code are "exec"uted in a Python dict that contains mappings from
{"circle" : actual_command_that_draws_circles, # other dict definitions here }

The actual code (inside Crunchy) used to process the code entered by
the user looks something like:
exec user_code in graphics_dict

and the resulting output is the javascript code required to produce a
graphics in the browser.

To allow a possible translation of the commands, the string "circle"
is actually written in the code as
following the standard "gettext" notation to denote strings that can
be translated.  At present the function
simply returns "args".  When translation is introduced, _() is
redefined and returns the translated value provided by the "catalog".
Thus, I can have in the catalog the correspondance
"cercle" <--> "circle"
which will mean that the Python code
_("circle"): actual_command_that_draws_circles
will actually be taken to mean
"cercle": actual_command_that_draws_circles

Note that we've only provided translations for Crunchy-specific
commands, like the graphics api.  In theory, it would be possible to
do the same for Python functions/methods i.e. we
could have a translation of
but that would be rather silly and not very helpful for someone who
wants to learn Python.

This is a rather brief description and I will gladly attempt to
clarify any specific point.


> - d
> _______________________________________________
> Edu-sig mailing list
> Edu-sig at python.org
> http://mail.python.org/mailman/listinfo/edu-sig

More information about the Edu-sig mailing list