[Python-ideas] PEP 501 - i18n with marked strings
M.-A. Lemburg
mal at egenix.com
Tue Aug 11 15:05:37 CEST 2015
On 10.08.2015 22:31, Mike Miller wrote:
> Hi,
>
> I haven't done i18n recently, so bare with me. I'm not sure about bolting this on to "format
> strings", in that it feels like an orthogonal concept.
>
> However, what if we had i18n strings as well, not instead of:
>
> i'Hello there, $name {age}.'
>
> and that they were complimentary to f'', each handling their different duties:
>
> fi'Hello there, $name {age}.'
>
> Different syntax would probably be needed for each, is that correct? Since each have different
> requirements, e.g. Barry's concerns about format strings being too powerful for non-developers,
> while also making a project vulnerable to arbitrary code.
>
> Perhaps PEP 498 with non-arbitrary strings (but attribute/keys support) would allow the syntax to be
> unified.
IMO, having just one string literal interpolation standard is better
than having two and since i"" fits both needs, I'm +1 on i"" and
-0 on f"".
The only problem I see with i"" is that you may want to use
formatting only in some cases, without triggering the translation
machinery which may be active in a module. I guess it's fine to
fallback to the standard .format() or %-approach for those
few situations, though.
In all other use cases, having the literal strings already
prepared for translation in a Python module is a huge win:
just drop a translation hook into the module and you're
good to go :-)
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, Aug 11 2015)
>>> Python Projects, Coaching and Consulting ... http://www.egenix.com/
>>> mxODBC Plone/Zope Database Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
::::: Try our mxODBC.Connect Python Database Interface for free ! ::::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
http://www.egenix.com/company/contact/
More information about the Python-ideas
mailing list