<div dir="ltr"><div><div>Monty, Xu.<br><br></div>Well I only spent 10min looking at gettext so I don't know much about the code, but its the process until it goes into fallback is what I'm concerned of.<br><br></div>
Everytime tranlsation() gets called, it invokes find() which looks up a mofile. Doesn't file IO occur here? I though there was a part where it exit by only looking at the locale but failed to find it.<br></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Sat, Jan 5, 2013 at 4:59 PM, Xu He Jie <span dir="ltr"><<a href="mailto:xuhj@linux.vnet.ibm.com" target="_blank">xuhj@linux.vnet.ibm.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF"><div><div class="h5">
<div>On 2013年01月05日 16:43, Zhongyue Luo
wrote:<br>
</div>
</div></div><blockquote type="cite"><div><div class="h5">
<div dir="ltr">Hi all,<br>
<div><br>
I understand that i18n is an important feature to customers
and that having gettextutils wrapped on all log messages will
benefit<br>
in packing custom .pot files to ship with a product.<br>
<br>
</div>
<div>However seeing the number of _()'s increasing in source
code, its now kind of bothering me now to see all the messages
go through<br>
</div>
<div>the heavy process of gettext.translation() even when I
don't need i18n.<br>
<br>
</div>
<div>Therefore I propose a flag, e.g i18n=true|false, so that a
developer can choose the behavior of the _().<br>
<br>
</div>
<div>in openstack.common.gettextutils.py...<br>
<br>
</div>
<div>def _(msg):<br>
</div>
<div>
if cfg.CONF.i18n:<br>
return t.ugettext(msg)<br>
</div>
<div> else:<br>
</div>
<div> return msg<br>
<br>
</div>
<div>Well you can have the if/else outside of the function to
prevent looking up the conf every time it gets called but you
get the idea.<br>
<br>
</div>
<div>Any thoughts?<br>
</div>
</div>
<br>
<fieldset></fieldset>
<br>
</div></div><div class="im"><pre>_______________________________________________
OpenStack-dev mailing list
<a href="mailto:OpenStack-dev@lists.openstack.org" target="_blank">OpenStack-dev@lists.openstack.org</a>
<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>
</pre>
</div></blockquote>
When gettext.install can't find the right translation domain, it
will return NullTranslation object.<br>
The 'ugettext' implement of NullTranslation as below:<br>
def ugettext(self, message):<br>
if self._fallback:<br>
return self._fallback.ugettext(message)<br>
return unicode(message)<br>
<br>
It looks like it's not too heavy. So I think it's ok.<br>
</div>
<br>_______________________________________________<br>
OpenStack-dev mailing list<br>
<a href="mailto:OpenStack-dev@lists.openstack.org">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></blockquote></div><br><br clear="all"><br>-- <br><div><b>Intel SSG/SSD/SOTC/PRC/CITT</b></div>
<div>880 Zixing Road, Zizhu Science Park, Minhang District, Shanghai, 200241,
China<br></div>
<div>+862161166500</div>
</div>