[openstack-dev] _() consensus??

Zhongyue Luo zhongyue.nah at intel.com
Sat Jan 5 09:28:22 UTC 2013


Oh I understand now. Ignore my comments


On Sat, Jan 5, 2013 at 5:14 PM, Zhongyue Luo <zhongyue.nah at intel.com> wrote:

> Monty, Xu.
>
> 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.
>
> 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.
>
>
> On Sat, Jan 5, 2013 at 4:59 PM, Xu He Jie <xuhj at linux.vnet.ibm.com> wrote:
>
>>  On 2013年01月05日 16:43, Zhongyue Luo wrote:
>>
>> Hi all,
>>
>> I understand that i18n is an important feature to customers and that
>> having gettextutils wrapped on all log messages will benefit
>> in packing custom .pot files to ship with a product.
>>
>>  However seeing the number of _()'s increasing in source code, its now
>> kind of bothering me now to see all the messages go through
>>  the heavy process of gettext.translation() even when I don't need i18n.
>>
>>  Therefore I propose a flag, e.g i18n=true|false, so that a developer
>> can choose the behavior of the _().
>>
>>  in openstack.common.gettextutils.py...
>>
>>  def _(msg):
>>     if cfg.CONF.i18n:
>>        return t.ugettext(msg)
>>     else:
>>         return msg
>>
>>  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.
>>
>>  Any thoughts?
>>
>>
>> _______________________________________________
>> OpenStack-dev mailing listOpenStack-dev at lists.openstack.orghttp://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>>
>>  When gettext.install can't find the right translation domain, it will
>> return NullTranslation object.
>> The 'ugettext' implement of NullTranslation as below:
>>     def ugettext(self, message):
>>         if self._fallback:
>>             return self._fallback.ugettext(message)
>>         return unicode(message)
>>
>> It looks like it's not too heavy. So I think it's ok.
>>
>> _______________________________________________
>> OpenStack-dev mailing list
>> OpenStack-dev at lists.openstack.org
>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>>
>>
>
>
> --
> *Intel SSG/SSD/SOTC/PRC/CITT*
> 880 Zixing Road, Zizhu Science Park, Minhang District, Shanghai, 200241,
> China
> +862161166500
>



-- 
*Intel SSG/SSD/SOTC/PRC/CITT*
880 Zixing Road, Zizhu Science Park, Minhang District, Shanghai, 200241,
China
+862161166500
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20130105/73b6fe58/attachment.html>


More information about the OpenStack-dev mailing list