Use i18n directly

We should use i18n directly rather than openstack/common.

Change-Id: I64d3abce4ee2747b670bc921ffbb03d76defd42c
This commit is contained in:
wangxiyuan
2015-11-13 15:29:09 +08:00
parent 0c348313a4
commit 57be02dcd2
5 changed files with 39 additions and 7 deletions

View File

@@ -8,7 +8,7 @@ PasteDeploy==1.5.2
oslo.messaging==1.16.0
oslo.db==2.1.0
oslo.log>=1.8.0 # Apache-2.0
oslo.i18n==2.1.0
oslo.i18n>=1.5.0 # Apache-2.0
oslo.utils==1.8.0 # Apache-2.0
pecan>=0.8
keystonemiddleware>=1.0.0

View File

@@ -25,11 +25,11 @@ from oslo_config import cfg
from oslo_log import log as logging
from watcher.applier.framework.manager_applier import ApplierManager
from watcher.openstack.common._i18n import _LI
from watcher import i18n
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
_LI = i18n._LI
def main():

View File

@@ -26,7 +26,8 @@ from oslo_log import log as logging
from watcher.decision_engine.framework.manager_decision_engine import \
DecisionEngineManager
from watcher.openstack.common._i18n import _LI
from watcher import i18n
cfg.CONF.import_opt('hostname',
'watcher.metrics_engine.framework.'
'datasources.influxdb_collector',
@@ -34,6 +35,7 @@ cfg.CONF.import_opt('hostname',
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
_LI = i18n._LI
def main():

View File

@@ -29,13 +29,12 @@ from watcher.common import exception
from watcher.common import utils
from watcher.db import api
from watcher.db.sqlalchemy import models
from watcher import i18n
from watcher.objects.audit import AuditStatus
from watcher.openstack.common._i18n import _
CONF = cfg.CONF
LOG = log.getLogger(__name__)
_ = i18n._
_FACADE = None

31
watcher/i18n.py Normal file
View File

@@ -0,0 +1,31 @@
# Copyright 2014 Huawei Crop.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_i18n import * # noqa
_translators = TranslatorFactory(domain='glance')
# The primary translation function using the well-known name "_"
_ = _translators.primary
# Translators for log levels.
#
# The abbreviated names are meant to reflect the usual use of a short
# name like '_'. The "L" is for "log" and the other letter comes from
# the level.
_LI = _translators.log_info
_LW = _translators.log_warning
_LE = _translators.log_error
_LC = _translators.log_critical