[Localization] Turtle Art oops

Walter Bender walter.bender at gmail.com
Mon Sep 26 19:47:32 EDT 2011


I realized that I made a mistake re i18n in recent Turtle Art builds.
In the process of consolidating the code used to generate blocks for
constants, I used a subroutine:

    from gettext import gettext as _

    def _make_constant(self, palette, block_name, constant):
        """ Factory for constant blocks """
        palette.add_block(block_name,
                                  style='box-style',
                                  label=_(block_name),
                                  prim_name=block_name,
                                  logo_command=block_name)

I call this routine as follows:

        self._make_constant(palette, 'red', CONSTANTS['red'])
        self._make_constant(palette, 'orange', CONSTANTS['orange'])
        self._make_constant(palette, 'yellow', CONSTANTS['yellow'])
        self._make_constant(palette, 'green', CONSTANTS['green'])
        self._make_constant(palette, 'cyan', CONSTANTS['cyan'])
        self._make_constant(palette, 'blue', CONSTANTS['blue'])
        self._make_constant(palette, 'purple', CONSTANTS['purple'])
        self._make_constant(palette, 'white', WHITE)
        self._make_constant(palette, 'black', BLACK)

The problem is that the color names are never seen by the genpot
process. They are found during program execution and since the color
names were already in the PO files (marked as fuzzy), there shouldn't
be a problem for those of you who made translations earlier. But the
more recent po files won't have these strings.

I have a simple patch to fix this, but I will need to violate string freeze.

    def _make_constant(self, palette, block_name, label, constant):
        """ Factory for constant blocks """
        palette.add_block(block_name, style='box-style',
                          label=label, prim_name=block_name,
                          logo_command=block_name)

        self._make_constant(palette, 'red', _('red'), CONSTANTS['red'])
        self._make_constant(palette, 'orange', _('orange'),
                            CONSTANTS['orange'])
        self._make_constant(palette, 'yellow', _('yellow'),
                            CONSTANTS['yellow'])
        self._make_constant(palette, 'green', _('green'), CONSTANTS['green'])
        self._make_constant(palette, 'cyan', _('cyan'), CONSTANTS['cyan'])
        self._make_constant(palette, 'blue', _('blue'), CONSTANTS['blue'])
        self._make_constant(palette, 'purple', _('purple'),
                            CONSTANTS['purple'])
        self._make_constant(palette, 'white', _('white'), WHITE)
        self._make_constant(palette, 'black', _('black'), BLACK)


regards.

-walter


-- 
Walter Bender
Sugar Labs
http://www.sugarlabs.org


More information about the Localization mailing list