<div>i18n support prevents us from doing something like:</div><div><div><pre style="margin-top:15px;margin-bottom:15px;padding:6px 10px;border:1px solid rgb(204,204,204);font-size:13px;font-family:Consolas,'Liberation Mono',Courier,monospace;background-color:rgb(248,248,248);line-height:19px;overflow:auto;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(51,51,51)">
_("The server with id %()s has no key %s" % (s_id, m_key))</pre></div><div></div></div><div>Because translations my reverse the sentence structures. So the two options are:</div><div><pre style="margin-top:15px;margin-bottom:15px;padding:6px 10px;border:1px solid rgb(204,204,204);font-size:13px;font-family:Consolas,'Liberation Mono',Courier,monospace;background-color:rgb(248,248,248);line-height:19px;overflow:auto;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(51,51,51)">
_("The server with id %(s_id)s has no key %(m_key)s" % locals())</pre></div><div>and </div><div><pre style="margin-top:15px;margin-bottom:15px;padding:6px 10px;border:1px solid rgb(204,204,204);font-size:13px;font-family:Consolas,'Liberation Mono',Courier,monospace;background-color:rgb(248,248,248);line-height:19px;overflow:auto;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(51,51,51)">
msg = _("The server with id %(s_id)s has no key %(m_key)s")
LOG.error(msg % {"s_id": "1234", "m_key": "imageId"})</pre></div><div><br></div><a href="https://github.com/openstack/nova/blob/master/HACKING.rst#internationalization-i18n-strings" target="_blank">https://github.com/openstack/nova/blob/master/HACKING.rst#internationalization-i18n-strings</a><br>
<br><div class="gmail_quote">On Thu, Feb 7, 2013 at 11:49 AM, Jay Pipes <span dir="ltr"><<a href="mailto:jaypipes@gmail.com" target="_blank">jaypipes@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I actually prefer the use of locals()... I find it cleaner that<br>
specifying huge dictionaries to supply for string interpolation.<br>
<span><font color="#888888"><br>
-jay<br>
</font></span><div><div><br>
On 02/07/2013 02:33 PM, Andrew Laski wrote:<br>
> On 02/07/13 at 10:23am, Nachi Ueno wrote:<br>
>> Hi folks<br>
>><br>
>> I wanna ask the opinion of use of local()<br>
>> This function is mainly used for logging because of no need to specify<br>
>> actual parameters.<br>
>><br>
>> However, the variable ,which code checker says it is not used, is used<br>
>> by local() sometimes.<br>
>> so I prefer not to use local() .<br>
>> I also believe to specify used parameter improves readability of the code.<br>
><br>
> I agree. I prefer the explicitness of passing variables to string<br>
> interpolation, and my style checker also picks up the variables which it<br>
> thinks are not used.<br>
><br>
> I would support a check in hacking.py for this in Nova but personally<br>
> don't think reviewers should spend time worrying about it. Which means<br>
> that I think it's an uphill battle for projects without something like<br>
> hacking.py.<br>
><br>
><br>
>><br>
>> I appreciate if I could get the opinion on the community.<br>
>><br>
>> Thanks<br>
>> Nachi<br>
>><br>
>> _______________________________________________<br>
>> OpenStack-dev mailing list<br>
>> <a href="mailto:OpenStack-dev@lists.openstack.org" target="_blank">OpenStack-dev@lists.openstack.org</a><br>
>> <a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
><br>
> _______________________________________________<br>
> OpenStack-dev mailing list<br>
> <a href="mailto:OpenStack-dev@lists.openstack.org" target="_blank">OpenStack-dev@lists.openstack.org</a><br>
> <a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
><br>
<br>
_______________________________________________<br>
OpenStack-dev mailing list<br>
<a href="mailto:OpenStack-dev@lists.openstack.org" target="_blank">OpenStack-dev@lists.openstack.org</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
</div></div></blockquote></div><br>