diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-04-15 06:38:40 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-04-15 06:38:40 +0000 |
| commit | 9d52e07f602e9afd5ef730bf6399228975fac16f (patch) | |
| tree | 33fce315dc83f7af2a26721fb94053cd95b5a14d /nova/openstack | |
| parent | 0fc0588a41d85a61695f4fa0aab238784ffe5999 (diff) | |
| parent | 5e7ef210c01d3db8c79b969da3aeda50d57c4923 (diff) | |
| download | nova-9d52e07f602e9afd5ef730bf6399228975fac16f.tar.gz nova-9d52e07f602e9afd5ef730bf6399228975fac16f.tar.xz nova-9d52e07f602e9afd5ef730bf6399228975fac16f.zip | |
Merge "Add NOVA_LOCALEDIR env variable"
Diffstat (limited to 'nova/openstack')
| -rw-r--r-- | nova/openstack/common/gettextutils.py | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/nova/openstack/common/gettextutils.py b/nova/openstack/common/gettextutils.py index b9993b491..2d2e94a7c 100644 --- a/nova/openstack/common/gettextutils.py +++ b/nova/openstack/common/gettextutils.py @@ -24,10 +24,27 @@ Usual usage in an openstack.common module: """ import gettext +import os - -t = gettext.translation('nova', 'locale', fallback=True) +_localedir = os.environ.get('nova'.upper() + '_LOCALEDIR') +_t = gettext.translation('nova', localedir=_localedir, fallback=True) def _(msg): - return t.ugettext(msg) + return _t.ugettext(msg) + + +def install(domain): + """Install a _() function using the given translation domain. + + Given a translation domain, install a _() function using gettext's + install() function. + + The main difference from gettext.install() is that we allow + overriding the default localedir (e.g. /usr/share/locale) using + a translation-domain-specific environment variable (e.g. + NOVA_LOCALEDIR). + """ + gettext.install(domain, + localedir=os.environ.get(domain.upper() + '_LOCALEDIR'), + unicode=True) |
