[I18n-sig] Re: pygettext dilemma
Martin v. Loewis
martin@loewis.home.cs.tu-berlin.de
Wed, 15 Aug 2001 07:54:16 +0200
> Now we all know that this won't do as a source string because there
> may be some languages may change the order of the variables, so we
> really need to write the string like so:
>
> _('No such list %(listname)s found on host %(hostname)s') % {
> 'listname': listname,
> 'hostname': hostname
> }
>
> I've found this style to be quite pervasive, but also extremely (and
> unnecessarily) repetitive. Notice that I've typed "listname" and
> "hostname" a total of six times. Wouldn't it be wonderful if I only
> needed to type them once:
What's wrong with
_('No such list %(listname)s found on host %(hostname)s') % locals()
No magic required; of course, this assumes that the variables are
either all globals or all locals - I wish vars() would give me a
dictionary of all variables (perhaps even including the builtins).
Regards,
Martin