From 6338d4656cb71aeeee2e1a9facb22278e208aa00 Mon Sep 17 00:00:00 2001 From: "Jay S. Bryant" Date: Fri, 31 Jan 2014 16:46:29 -0600 Subject: [PATCH] Re-enable lazy translation This patch re-enables lazy translation to enable REST API responses to be translated to the requested locale (I.E. setting 'Accept-Language: zh-CN'.) This patch also removes the unnecessary manual import of 'cinder.openstack.common.gettextutils _' in Cinder code. Since _ is still being imported in the cinder.openstack.common files from Oslo we still need to set gettexttutils.enable_lazy(). enable_lazy will be able to be removed once the manual imports of _ have been removed from Oslo. implements-bp: i18n-messages Change-Id: I0b5a35a2cc28d97d12ceccccd58565b487fef428 --- bin/cinder-all | 3 ++- bin/cinder-api | 3 ++- bin/cinder-backup | 3 ++- bin/cinder-clear-rabbit-queues | 3 ++- bin/cinder-manage | 3 ++- bin/cinder-rtstool | 5 +++-- bin/cinder-scheduler | 3 ++- bin/cinder-volume | 3 ++- bin/cinder-volume-usage-audit | 3 ++- cinder/api/contrib/quotas.py | 1 - cinder/api/v1/limits.py | 1 - cinder/brick/exception.py | 1 - cinder/brick/initiator/connector.py | 1 - cinder/brick/initiator/linuxfc.py | 1 - cinder/brick/initiator/linuxscsi.py | 1 - cinder/brick/local_dev/lvm.py | 1 - cinder/brick/remotefs/remotefs.py | 1 - cinder/common/config.py | 2 -- cinder/db/sqlalchemy/migrate_repo/manage.py | 3 ++- cinder/exception.py | 1 - cinder/keymgr/conf_key_mgr.py | 1 - cinder/policy.py | 1 - 22 files changed, 21 insertions(+), 24 deletions(-) diff --git a/bin/cinder-all b/bin/cinder-all index a3b2fcf7f..c14d8e634 100755 --- a/bin/cinder-all +++ b/bin/cinder-all @@ -42,7 +42,8 @@ if os.path.exists(os.path.join(possible_topdir, "cinder", "__init__.py")): sys.path.insert(0, possible_topdir) from cinder.openstack.common import gettextutils -gettextutils.install('cinder', lazy=False) +gettextutils.enable_lazy() +gettextutils.install('cinder', lazy=True) # Need to register global_opts from cinder.common import config # noqa diff --git a/bin/cinder-api b/bin/cinder-api index 953575c9e..0c6529b0f 100755 --- a/bin/cinder-api +++ b/bin/cinder-api @@ -32,7 +32,8 @@ if os.path.exists(os.path.join(possible_topdir, "cinder", "__init__.py")): sys.path.insert(0, possible_topdir) from cinder.openstack.common import gettextutils -gettextutils.install('cinder', lazy=False) +gettextutils.enable_lazy() +gettextutils.install('cinder', lazy=True) # Need to register global_opts from cinder.common import config # noqa diff --git a/bin/cinder-backup b/bin/cinder-backup index 2b5a634cc..9de9ba605 100755 --- a/bin/cinder-backup +++ b/bin/cinder-backup @@ -36,7 +36,8 @@ if os.path.exists(os.path.join(possible_topdir, 'cinder', '__init__.py')): sys.path.insert(0, possible_topdir) from cinder.openstack.common import gettextutils -gettextutils.install('cinder') +gettextutils.enable_lazy() +gettextutils.install('cinder', lazy=True) # Need to register global_opts from cinder.common import config # noqa diff --git a/bin/cinder-clear-rabbit-queues b/bin/cinder-clear-rabbit-queues index 4a59b8b3d..51aa217f0 100755 --- a/bin/cinder-clear-rabbit-queues +++ b/bin/cinder-clear-rabbit-queues @@ -35,7 +35,8 @@ if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'cinder', '__init__.py')): sys.path.insert(0, POSSIBLE_TOPDIR) from cinder.openstack.common import gettextutils -gettextutils.install('cinder') +gettextutils.enable_lazy() +gettextutils.install('cinder', lazy=True) # Need to register global_opts from cinder.common import config # noqa diff --git a/bin/cinder-manage b/bin/cinder-manage index 7b113c865..5a47bdf89 100755 --- a/bin/cinder-manage +++ b/bin/cinder-manage @@ -70,7 +70,8 @@ if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'cinder', '__init__.py')): sys.path.insert(0, POSSIBLE_TOPDIR) from cinder.openstack.common import gettextutils -gettextutils.install('cinder') +gettextutils.enable_lazy() +gettextutils.install('cinder', lazy=True) # Need to register global_opts from cinder.common import config # noqa diff --git a/bin/cinder-rtstool b/bin/cinder-rtstool index 07fe5947d..6cbf44472 100755 --- a/bin/cinder-rtstool +++ b/bin/cinder-rtstool @@ -16,13 +16,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import gettext +import gettextutils import re import sys import rtslib -gettext.install('cinder-rtstool', unicode=1) +gettextutils.enable_lazy() +gettextutils.install('cinder-rtstool', lazy=True) class RtstoolError(Exception): diff --git a/bin/cinder-scheduler b/bin/cinder-scheduler index e8ee1175b..6281fbbd4 100755 --- a/bin/cinder-scheduler +++ b/bin/cinder-scheduler @@ -36,7 +36,8 @@ if os.path.exists(os.path.join(possible_topdir, 'cinder', '__init__.py')): sys.path.insert(0, possible_topdir) from cinder.openstack.common import gettextutils -gettextutils.install('cinder') +gettextutils.enable_lazy() +gettextutils.install('cinder', lazy=True) # Need to register global_opts from cinder.common import config # noqa diff --git a/bin/cinder-volume b/bin/cinder-volume index 0a04626c3..e9af49cf3 100755 --- a/bin/cinder-volume +++ b/bin/cinder-volume @@ -40,7 +40,8 @@ if os.path.exists(os.path.join(possible_topdir, 'cinder', '__init__.py')): sys.path.insert(0, possible_topdir) from cinder.openstack.common import gettextutils -gettextutils.install('cinder') +gettextutils.enable_lazy() +gettextutils.install('cinder', lazy=True) # Need to register global_opts from cinder.common import config # noqa diff --git a/bin/cinder-volume-usage-audit b/bin/cinder-volume-usage-audit index 53ea460ae..fd6dcd196 100755 --- a/bin/cinder-volume-usage-audit +++ b/bin/cinder-volume-usage-audit @@ -50,7 +50,8 @@ if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'cinder', '__init__.py')): sys.path.insert(0, POSSIBLE_TOPDIR) from cinder.openstack.common import gettextutils -gettextutils.install('cinder') +gettextutils.enable_lazy() +gettextutils.install('cinder', lazy=True) from cinder import context from cinder import db diff --git a/cinder/api/contrib/quotas.py b/cinder/api/contrib/quotas.py index 739eb1e2e..a950cbc02 100644 --- a/cinder/api/contrib/quotas.py +++ b/cinder/api/contrib/quotas.py @@ -21,7 +21,6 @@ from cinder.api import xmlutil from cinder import db from cinder.db.sqlalchemy import api as sqlalchemy_api from cinder import exception -from cinder.openstack.common.gettextutils import _ from cinder.openstack.common import strutils from cinder import quota diff --git a/cinder/api/v1/limits.py b/cinder/api/v1/limits.py index de70243f9..76a1a3752 100644 --- a/cinder/api/v1/limits.py +++ b/cinder/api/v1/limits.py @@ -30,7 +30,6 @@ import webob.exc from cinder.api.openstack import wsgi from cinder.api.views import limits as limits_views from cinder.api import xmlutil -from cinder.openstack.common.gettextutils import _ from cinder.openstack.common import importutils from cinder.openstack.common import jsonutils from cinder import quota diff --git a/cinder/brick/exception.py b/cinder/brick/exception.py index 59a953c79..fda13d6ec 100644 --- a/cinder/brick/exception.py +++ b/cinder/brick/exception.py @@ -14,7 +14,6 @@ """Exceptions for the Brick library.""" -from cinder.openstack.common.gettextutils import _ from cinder.openstack.common import log as logging diff --git a/cinder/brick/initiator/connector.py b/cinder/brick/initiator/connector.py index 3ffc6b590..57a9076a8 100644 --- a/cinder/brick/initiator/connector.py +++ b/cinder/brick/initiator/connector.py @@ -23,7 +23,6 @@ from cinder.brick.initiator import host_driver from cinder.brick.initiator import linuxfc from cinder.brick.initiator import linuxscsi from cinder.brick.remotefs import remotefs -from cinder.openstack.common.gettextutils import _ from cinder.openstack.common import lockutils from cinder.openstack.common import log as logging from cinder.openstack.common import loopingcall diff --git a/cinder/brick/initiator/linuxfc.py b/cinder/brick/initiator/linuxfc.py index 2b6099c82..fe43046f0 100644 --- a/cinder/brick/initiator/linuxfc.py +++ b/cinder/brick/initiator/linuxfc.py @@ -17,7 +17,6 @@ import errno from cinder.brick.initiator import linuxscsi -from cinder.openstack.common.gettextutils import _ from cinder.openstack.common import log as logging from cinder.openstack.common import processutils as putils diff --git a/cinder/brick/initiator/linuxscsi.py b/cinder/brick/initiator/linuxscsi.py index 83e41d99d..9b2c776df 100644 --- a/cinder/brick/initiator/linuxscsi.py +++ b/cinder/brick/initiator/linuxscsi.py @@ -19,7 +19,6 @@ import os from cinder.brick import executor -from cinder.openstack.common.gettextutils import _ from cinder.openstack.common import log as logging from cinder.openstack.common import processutils as putils diff --git a/cinder/brick/local_dev/lvm.py b/cinder/brick/local_dev/lvm.py index 6b51316f1..8e5a09bfb 100644 --- a/cinder/brick/local_dev/lvm.py +++ b/cinder/brick/local_dev/lvm.py @@ -24,7 +24,6 @@ import itertools from cinder.brick import exception from cinder.brick import executor -from cinder.openstack.common.gettextutils import _ from cinder.openstack.common import log as logging from cinder.openstack.common import processutils as putils diff --git a/cinder/brick/remotefs/remotefs.py b/cinder/brick/remotefs/remotefs.py index c68e18b88..62a8f18cf 100755 --- a/cinder/brick/remotefs/remotefs.py +++ b/cinder/brick/remotefs/remotefs.py @@ -21,7 +21,6 @@ import re import six from cinder.brick import exception -from cinder.openstack.common.gettextutils import _ from cinder.openstack.common import log as logging from cinder.openstack.common import processutils as putils diff --git a/cinder/common/config.py b/cinder/common/config.py index 969f8c3c1..86def4407 100644 --- a/cinder/common/config.py +++ b/cinder/common/config.py @@ -29,8 +29,6 @@ import socket from oslo.config import cfg -from cinder.openstack.common.gettextutils import _ - CONF = cfg.CONF diff --git a/cinder/db/sqlalchemy/migrate_repo/manage.py b/cinder/db/sqlalchemy/migrate_repo/manage.py index a714db624..101cea379 100755 --- a/cinder/db/sqlalchemy/migrate_repo/manage.py +++ b/cinder/db/sqlalchemy/migrate_repo/manage.py @@ -18,7 +18,8 @@ import os from oslo.config import cfg from cinder.openstack.common import gettextutils -gettextutils.install('cinder', lazy=False) +gettextutils.enable_lazy() +gettextutils.install('cinder', lazy=True) from cinder.db.sqlalchemy import migrate_repo from cinder import version diff --git a/cinder/exception.py b/cinder/exception.py index 03688a1dd..8ef9c7cb6 100644 --- a/cinder/exception.py +++ b/cinder/exception.py @@ -27,7 +27,6 @@ import sys from oslo.config import cfg import webob.exc -from cinder.openstack.common.gettextutils import _ from cinder.openstack.common import log as logging diff --git a/cinder/keymgr/conf_key_mgr.py b/cinder/keymgr/conf_key_mgr.py index 9915bfe57..faad47e17 100644 --- a/cinder/keymgr/conf_key_mgr.py +++ b/cinder/keymgr/conf_key_mgr.py @@ -38,7 +38,6 @@ from oslo.config import cfg from cinder import exception from cinder.keymgr import key from cinder.keymgr import key_mgr -from cinder.openstack.common.gettextutils import _ from cinder.openstack.common import log as logging diff --git a/cinder/policy.py b/cinder/policy.py index 9e3999efa..43cc0a718 100644 --- a/cinder/policy.py +++ b/cinder/policy.py @@ -19,7 +19,6 @@ from oslo.config import cfg from cinder import exception -from cinder.openstack.common.gettextutils import _ from cinder.openstack.common import policy from cinder import utils -- 2.45.2