Comment 8 for bug 995287

Revision history for this message
Mark McLoughlin (markmc) wrote : Re: actually use translated strings

The issue here is that, for each translation domain, we need to support configuring the localedir.

At first thought, it might seem like this should be configurable via the CLI and config files (i.e. using cfg) but this needs to be configured before we ever translate a single message ... and we need to support translating messages before cfg is ever called.

In C programs, you'd typically configure this at build-time and the localedir would be baked into the binaries. We don't really have an equivalent of that with Python.

The default localedir in Fedora is /usr/share/locale - so if we install nova.mo under /usr/share/locale/$lang/LC_MESSAGES then what we do now actually works fine. I assume this is true of all distros.

The case where we want to configure an alternative localedir is devstack - e.g. if you run 'python setup.py compile_catatlog', then nova.mo will be under /opt/stack/nova/nova/locale/$lang/LC_MESSAGES/

I think we should simply add support for this via env variables e.g.

  gettext.install('nova', unicode=1, localedir=os.environ.get('NOVA_LOCALEDIR'))

and you'd run e.g. nova-api in devstack with:

  $> NOVA_LOCALEDIR=/opt/stack/nova/nova/locale /opt/stack/nova/bin/nova-api