Re: Re: pygettext dilemma

"Martin v. Loewis" <[email protected]>
Newsgroups gmane.comp.python.internationalization
Message-ID <[email protected]>
> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.