Skip to content

Commit

Permalink
Import oslo.i18n and port heat bins to use oslo.i18n
Browse files Browse the repository at this point in the history
Import oslo.i18n and port heat bins to use oslo.i18n

blueprint oslo-i18n

Change-Id: If30df87d7d2b8047225f0c413d338ace975062b1
  • Loading branch information
Ethan Lynn committed Sep 2, 2014
1 parent 12b3bd4 commit d5c449a
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 17 deletions.
6 changes: 3 additions & 3 deletions bin/heat-api
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ if os.path.exists(os.path.join(possible_topdir, 'heat', '__init__.py')):
sys.path.insert(0, possible_topdir)

from oslo.config import cfg
from oslo import i18n

from heat.common import config
from heat.common.i18n import _
from heat.common import messaging
from heat.common import wsgi
from heat.openstack.common import gettextutils
from heat.openstack.common import log as logging
from heat.openstack.common import systemd

gettextutils.enable_lazy()
gettextutils.install('heat', lazy=True)
i18n.enable_lazy()

LOG = logging.getLogger('heat.api')

Expand Down
7 changes: 3 additions & 4 deletions bin/heat-api-cfn
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,16 @@ if os.path.exists(os.path.join(possible_topdir, 'heat', '__init__.py')):
sys.path.insert(0, possible_topdir)

from oslo.config import cfg
from oslo import i18n

from heat.common import config
from heat.common.i18n import _
from heat.common import messaging
from heat.common import wsgi
from heat.openstack.common import gettextutils

from heat.openstack.common import log as logging
from heat.openstack.common import systemd

gettextutils.enable_lazy()
gettextutils.install('heat', lazy=True)
i18n.enable_lazy()

LOG = logging.getLogger('heat.api.cfn')

Expand Down
7 changes: 3 additions & 4 deletions bin/heat-api-cloudwatch
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,16 @@ if os.path.exists(os.path.join(possible_topdir, 'heat', '__init__.py')):
sys.path.insert(0, possible_topdir)

from oslo.config import cfg
from oslo import i18n

from heat.common import config
from heat.common.i18n import _
from heat.common import messaging
from heat.common import wsgi
from heat.openstack.common import gettextutils

from heat.openstack.common import log as logging
from heat.openstack.common import systemd

gettextutils.enable_lazy()
gettextutils.install('heat', lazy=True)
i18n.enable_lazy()

LOG = logging.getLogger('heat.api.cloudwatch')

Expand Down
5 changes: 2 additions & 3 deletions bin/heat-engine
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,15 @@ if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'heat', '__init__.py')):
sys.path.insert(0, POSSIBLE_TOPDIR)

from oslo.config import cfg
from oslo import i18n

from heat.common import messaging
from heat.openstack.common import gettextutils
from heat.openstack.common import log as logging
from heat.openstack.common import service

from heat.rpc import api as rpc_api

gettextutils.enable_lazy()
gettextutils.install('heat', lazy=True)
i18n.enable_lazy()

LOG = logging.getLogger('heat.engine')

Expand Down
3 changes: 0 additions & 3 deletions bin/heat-manage
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,5 @@ if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'heat', '__init__.py')):
sys.path.insert(0, POSSIBLE_TOPDIR)

from heat.cmd import manage
from heat.openstack.common import gettextutils

gettextutils.install('heat')

manage.main()
35 changes: 35 additions & 0 deletions heat/common/i18n.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2014 IBM Corp.
#
# 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.

# It's based on oslo.i18n usage in OpenStack Keystone project and
# recommendations from http://docs.openstack.org/developer/oslo.i18n/usage.html

from oslo import i18n


_translators = i18n.TranslatorFactory(domain='heat')

# 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
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ lxml>=2.3
netaddr>=0.7.6
oslo.config>=1.4.0.0a3
oslo.db>=0.2.0 # Apache-2.0
oslo.i18n>=0.2.0 # Apache-2.0
oslo.messaging>=1.3.0
PasteDeploy>=1.5.0
pbr>=0.6,!=0.7,<1.0
Expand Down

0 comments on commit d5c449a

Please sign in to comment.