summaryrefslogtreecommitdiffstats
path: root/openstack/common
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2013-04-01 02:08:43 +0100
committerMark McLoughlin <markmc@redhat.com>2013-04-03 19:12:21 -0400
commitc8f676bb54158d1a03aef231af920eeda9ebe1ba (patch)
tree83df281e7a305db2203017324a220ea0ed677fd6 /openstack/common
parentd8b66c7c1bb28672402f2bf1e410a1ee8fc4bfb6 (diff)
downloadoslo-c8f676bb54158d1a03aef231af920eeda9ebe1ba.tar.gz
oslo-c8f676bb54158d1a03aef231af920eeda9ebe1ba.tar.xz
oslo-c8f676bb54158d1a03aef231af920eeda9ebe1ba.zip
Support overriding oslo localedir too
Part of fixing bug #995287 Libraries need to translate strings according to their translation domain but they should not override the default _() builtin (which should only be installed by the top-level script) and instead should gettextutils._(). To support the case where message catalogs are installed in a non-default (and perhaps project-specific) location, we allow the default localedir to be override with a project-specific environment variable e.g. QUANTUMCLIENT_LOCALEDIR. The code makes it seem like OSLO_LOCALEDIR is the env variable we're adding but, in fact, update.py magically replaces 'oslo' with the project name. Change-Id: I62b66892a4e27892ee488d2884ffd2f40ab467ee
Diffstat (limited to 'openstack/common')
-rw-r--r--openstack/common/gettextutils.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/openstack/common/gettextutils.py b/openstack/common/gettextutils.py
index efc6ec2..e816f14 100644
--- a/openstack/common/gettextutils.py
+++ b/openstack/common/gettextutils.py
@@ -26,12 +26,12 @@ Usual usage in an openstack.common module:
import gettext
import os
-
-t = gettext.translation('oslo', 'locale', fallback=True)
+_localedir = os.environ.get('oslo'.upper() + '_LOCALEDIR')
+_t = gettext.translation('oslo', localedir=_localedir, fallback=True)
def _(msg):
- return t.ugettext(msg)
+ return _t.ugettext(msg)
def install(domain):