<div dir="ltr">Not exactly.<div><br></div><div>Take this string for instance:</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>f'hello {name}'</div></blockquote><div><br></div><div>And our FString implementation, very simple:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>class FString(str):</div><div> def __init__(self, value, **kwargs):</div><div> super().__init__(value.format(**self.kwargs))</div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div> self.value = value</div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div> self.kwargs = kwargs</div></blockquote><div><br></div><div><div>What the above f-string should do is create an instance of that class. This is just a compiler detail. A preprocessor step. Like this:</div></div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>FString('hello {name}', name=str(name))</div></blockquote><div><br></div><div>FString is just an str instance, it has the actual interpolated value, but it still contains the original uninterpolated string and all parameters (as strings as well.)</div><div><br></div><div>Now, what gettext can do, if we would wrap this string in the underscore function, is take the "value" attribute from this string FString, translate that, and apply the interpolation again.</div><div><br></div><div>This way, we are completely compatible with the format() call. There is no need at all for using globals/locals or _getframe(). The name bindings are static, this is lintable.</div><div><br></div><div>Please tell me if I'm missing something.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-08-11 19:12 GMT+02:00 Sven R. Kunze <span dir="ltr"><<a href="mailto:srkunze@mail.de" target="_blank">srkunze@mail.de</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I actually thought this was about a two-step process using lazy evaluation.<br>
<br>
This way {name:i18n} or {name:later} basically marks lazy evaluation.<br>
<br>
But as it seems, i'...' is more supposed to do all (translation + formatting) of this at once. My fault, sorry.<div class="HOEnZb"><div class="h5"><br>
<br>
On 11.08.2015 10:35, Petr Viktorin wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Tue, Aug 11, 2015 at 9:36 AM, Sven R. Kunze <<a href="mailto:srkunze@mail.de" target="_blank">srkunze@mail.de</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Also bare with me but couldn't i18n not just be another format spec?<br>
<br>
i'Hello there, {name:i18n} {age}.'<br>
</blockquote>
Usually it's not the substitutions that you need to translate, but the<br>
surrounding text.<br>
</blockquote>
<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</div></div></blockquote></div><br></div>