[PythonCAD] Translation

Art Haas ahaas at airmail.net
Mon Mar 19 19:01:20 CET 2007

On Sun, Mar 18, 2007 at 06:26:31PM -0700, Glenn Meader wrote:
> I notice a directory called po in the PythonCAD source that seems to be for
> translation of messages into Spanish.
> How does this work? How are these files used in combination with the Python
> source code?

The files in the 'po' directory are for internationalization. The file
'PythonCAD.pot' is the template file listing all the text in the code
that have been marked as translatable. If you read this file you'll see
each translatable string as 'msgid' and the various files in which this
string was found. This file, btw, is generated with the 'xgettext'

Someone wanting to add a translation to PythonCAD would copy the '.pot'
file into a new file named 'PythonCAD.${locale}.po', where '${locale}'
is the standard abbreviation for the language you are translating into.
The 'PythonCAD.es.po' is the Spanish translation. I suppose that someone
translating into a slightly different dialect of Spanish, such as one
spoken in Mexico, would use a ${locale} like 'es_mx' or something

After the translator finishes adding the translated strings, the '.po'
file is processed with the 'msgfmt' program to produce a file ending
with the '.mo' extension. It is this file that is used by the gettext
library to substitute translated strings for the english text in the

> I'd like to modify the English messages in the source to make it clearer
> what the user is supposed to do. Will this affect the translation files?

Yes. Ideally what happens is all the code changes affecting translatable
strings are completed several days prior to a release, and then the
people providing translations have a couple of days to update their
'.po' files.

My comments above are just a rough summary of how the localization of
programs using gettext work. The complete details can be found with
the gettext documentation.

Art Haas
Man once surrendering his reason, has no remaining guard against absurdities
the most monstrous, and like a ship without rudder, is the sport of every wind.

-Thomas Jefferson to James Smith, 1822

More information about the PythonCAD mailing list