]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Add CINDER_LOCALEDIR env variable
authorMark McLoughlin <markmc@redhat.com>
Wed, 8 May 2013 12:52:51 +0000 (13:52 +0100)
committerZhiteng Huang <zhiteng.huang@intel.com>
Mon, 13 May 2013 15:17:59 +0000 (23:17 +0800)
Part of fixing bug #995287

Syncs these two commits from oslo-incubator:

  Support overriding oslo localedir too
  Add a gettextutils.install() helper function

to get a new gettextutils.install() function which allows the default
localedir to be overwritten via an environment variable.

Note that gettextutils.install() must be called before any other cinder
modules are imported since some modules attempt to translate strings
at import time (e.g. in cinder.flags). This is broken and inefficient,
but fixing it involves adding something like sphinx's l_() function and
would be very invaisve.

Change-Id: I86562b3a65d371673bb21f7179eecc7602bc0775

bin/cinder-all
bin/cinder-api
bin/cinder-backup
bin/cinder-clear-rabbit-queues
bin/cinder-manage
bin/cinder-scheduler
bin/cinder-volume
bin/cinder-volume-usage-audit
doc/source/devref/il8n.rst

index 6cfeedcce9bcd5b599df96c7c15b864087eeb0e7..9591d1574fa7a597bb035351b34ee524d50285e7 100755 (executable)
@@ -30,7 +30,6 @@ continue attempting to launch the rest of the services.
 import eventlet
 eventlet.monkey_patch()
 
-import gettext
 import os
 import sys
 
@@ -40,7 +39,8 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(
 if os.path.exists(os.path.join(possible_topdir, "cinder", "__init__.py")):
     sys.path.insert(0, possible_topdir)
 
-gettext.install('cinder', unicode=1)
+from cinder.openstack.common import gettextutils
+gettextutils.install('cinder')
 
 from cinder import flags
 from cinder.openstack.common import log as logging
index 68c06782b83ccb4e51dc49c1ec35f1fe52c2f792..0f05b519c8e69c549586102593f57a229460cd9c 100755 (executable)
@@ -26,7 +26,6 @@
 import eventlet
 eventlet.monkey_patch()
 
-import gettext
 import os
 import sys
 
@@ -36,7 +35,8 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(
 if os.path.exists(os.path.join(possible_topdir, "cinder", "__init__.py")):
     sys.path.insert(0, possible_topdir)
 
-gettext.install('cinder', unicode=1)
+from cinder.openstack.common import gettextutils
+gettextutils.install('cinder')
 
 from cinder import flags
 from cinder.openstack.common import log as logging
index d0278a35ad573a2546b5b13b227217d0d2735c14..71f83006a29e28486a4ed3f77e67b6a01b3a45f2 100755 (executable)
@@ -17,7 +17,6 @@
 
 """Starter script for Cinder Volume Backup."""
 
-import gettext
 import os
 import sys
 
@@ -33,7 +32,8 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
 if os.path.exists(os.path.join(possible_topdir, 'cinder', '__init__.py')):
     sys.path.insert(0, possible_topdir)
 
-gettext.install('cinder', unicode=1)
+from cinder.openstack.common import gettextutils
+gettextutils.install('cinder')
 
 from cinder import flags
 from cinder.openstack.common import log as logging
index aa701706a333b72c53fead08994fabf67bb6b4c7..684a56578aedefc868ccc0f5dcd5fb7abc3d5b4b 100755 (executable)
@@ -24,7 +24,6 @@
 """
 
 import datetime
-import gettext
 import os
 import sys
 import time
@@ -37,8 +36,8 @@ POSSIBLE_TOPDIR = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
 if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'cinder', '__init__.py')):
     sys.path.insert(0, POSSIBLE_TOPDIR)
 
-gettext.install('cinder', unicode=1)
-
+from cinder.openstack.common import gettextutils
+gettextutils.install('cinder')
 
 from oslo.config import cfg
 
index c358757d2a7504c2426594a2914b421f440bc6ca..63f638fc435371115bf83b6445756cf1b8ce8c0d 100755 (executable)
@@ -54,7 +54,6 @@
   CLI interface for cinder management.
 """
 
-import gettext
 import os
 import sys
 import uuid
@@ -72,7 +71,8 @@ POSSIBLE_TOPDIR = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
 if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'cinder', '__init__.py')):
     sys.path.insert(0, POSSIBLE_TOPDIR)
 
-gettext.install('cinder', unicode=1)
+from cinder.openstack.common import gettextutils
+gettextutils.install('cinder')
 
 from oslo.config import cfg
 
index 33015b3cad81065a8bc454eb367f28b7aed27af3..28edd8bbf90a6ef81a88a162db2f4e7a7e4073d3 100755 (executable)
@@ -22,7 +22,6 @@
 import eventlet
 eventlet.monkey_patch()
 
-import gettext
 import os
 import sys
 
@@ -34,7 +33,8 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
 if os.path.exists(os.path.join(possible_topdir, 'cinder', '__init__.py')):
     sys.path.insert(0, possible_topdir)
 
-gettext.install('cinder', unicode=1)
+from cinder.openstack.common import gettextutils
+gettextutils.install('cinder')
 
 from cinder import flags
 from cinder.openstack.common import log as logging
index bf144830b261ee05f4fe2b861ff5312c0934e7b4..9c36238d667d918d809abfce1928e544edc831b5 100755 (executable)
@@ -22,7 +22,6 @@
 import eventlet
 eventlet.monkey_patch()
 
-import gettext
 import os
 import sys
 
@@ -34,7 +33,8 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
 if os.path.exists(os.path.join(possible_topdir, 'cinder', '__init__.py')):
     sys.path.insert(0, possible_topdir)
 
-gettext.install('cinder', unicode=1)
+from cinder.openstack.common import gettextutils
+gettextutils.install('cinder')
 
 from cinder import flags
 from cinder.openstack.common import log as logging
index 053de79a13d4c13c5d4359cc52670985a6aa5d37..13ea447a9f2e83141511f4802af115c0adc99b14 100755 (executable)
@@ -34,7 +34,6 @@
         Jan 1 through Dec 31 of the previous year.
 """
 
-import gettext
 import os
 import sys
 import traceback
@@ -47,7 +46,9 @@ POSSIBLE_TOPDIR = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
 if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'cinder', '__init__.py')):
     sys.path.insert(0, POSSIBLE_TOPDIR)
 
-gettext.install('cinder', unicode=1)
+from cinder.openstack.common import gettextutils
+gettextutils.install('cinder')
+
 from cinder import context
 from cinder import db
 from cinder import flags
index 7e53731d743083c27aaa8220bff2dcf30bade548..e175af477fedb233ff2bcf104e3439c3f8df3d4e 100644 (file)
@@ -24,8 +24,8 @@ in cinder/tests/test_localization.py.
 
 The ``_()`` function is brought into the global scope by doing::
 
-    import gettext
-    gettext.install("cinder", unicode=1)
+    from cinder.openstack.common import gettextutils
+    gettextutils.install("cinder")
 
 These lines are needed in any toplevel script before any cinder modules are
 imported. If this code is missing, it may result in an error that looks like::