<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 2013年01月05日 16:43, Zhongyue Luo
wrote:<br>
</div>
<blockquote
cite="mid:CAFf0h6dpw+5nZK+UGaLAxd9Uca+Gsf-Tnm9yBdde7q=F=05GTQ@mail.gmail.com"
type="cite">
<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 class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
OpenStack-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:OpenStack-dev@lists.openstack.org">OpenStack-dev@lists.openstack.org</a>
<a class="moz-txt-link-freetext" href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a>
</pre>
</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>
</body>
</html>