[Python-ideas] Fix the DRY problem (was Re: PEP 501 - i18n with marked strings)
Terry Reedy
tjreedy at udel.edu
Fri Aug 14 03:58:55 CEST 2015
On 8/13/2015 11:39 AM, Barry Warsaw wrote:
> On Aug 13, 2015, at 10:04 AM, Terry Reedy wrote:
>
>> For internationalization, the gettext.gettext translation call could be added
>> in one place, where the string is passed to tk, rather than 80 places in the
>> structure definition. An altered version of the menudefs walker could be
>> used to collect the menu strings for translation.
>
> That would require being able to translate non-literals.
I don't understand, Idle's menus are built from string literals -- no
variables, not interpolation -- like 'File', 'Open', 'Open Module', etc.
I think this is fairly typical.
> I'd need the same,
> and it would be okay if the translation call were spelled less conveniently,
> as long as it's possible to both extract and translate the source strings.
With table-driven ui creation, extraction for human translators and
replacement of the original by the translation can be done with a pair
of related functions.
With code-driven ui creation (as currently with Idle dialogs), an
extraction function may be possible (if the string literals are tagged
with keywords such as 'title=' or 'text=') but translation still
requires addition of a _() call for each arguments that needs translation.
--
Terry Jan Reedy
More information about the Python-ideas
mailing list