[openstack-dev] _() consensus??
zhongyue.nah at intel.com
Sat Jan 5 09:14:36 UTC 2013
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
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)
> 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
880 Zixing Road, Zizhu Science Park, Minhang District, Shanghai, 200241,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the OpenStack-dev