Remove deprecated function i18n.install('heat')

Since i18n.install() is deprecated, remove it from heat codes and
import i18n._() to where it needed.

blueprint oslo-i18n
Change-Id: Icefada18b5a33112b425cd90d31d3a6a5f06188a
This commit is contained in:
Ethan Lynn 2014-07-28 17:35:25 +08:00
parent ce2cc9f6f6
commit 11c1b62052
82 changed files with 100 additions and 30 deletions

View File

@ -13,6 +13,7 @@
# under the License.
from heat.common import exception
from heat.common.i18n import _
from heat.engine import properties
from heat.engine.resources.neutron import neutron

View File

@ -14,6 +14,7 @@
import six
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import clients
from heat.engine import constraints

View File

@ -14,6 +14,7 @@
import six
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import clients
from heat.engine import constraints

View File

@ -11,6 +11,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from heat.common.i18n import _
from heat.openstack.common import log as logging
LOG = logging.getLogger(__name__)

View File

@ -12,6 +12,7 @@
# under the License.
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import clients
from heat.engine import properties

View File

@ -15,6 +15,7 @@
import copy
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import constraints
from heat.engine import properties

View File

@ -17,6 +17,3 @@
from oslo import i18n
i18n.enable_lazy()
# fixme(elynn): Since install() is deprecated, we should remove it in
# the future
i18n.install('heat')

View File

@ -14,17 +14,11 @@
import routes
from webob import Request
from oslo import i18n
from heat.api.cloudwatch import versions
from heat.api.cloudwatch import watch
from heat.api.middleware.version_negotiation import VersionNegotiationFilter
from heat.common import wsgi
# FIXME(elynn): Since install() is deprecated, we should remove it in the
# future.
i18n.install('heat')
class API(wsgi.Router):

View File

@ -14,6 +14,7 @@
from webob import exc
from heat.api.openstack.v1 import util
from heat.common.i18n import _
from heat.common import serializers
from heat.common import wsgi
from heat.rpc import client as rpc_client

View File

@ -16,6 +16,7 @@ import itertools
from webob import exc
from heat.api.openstack.v1 import util
from heat.common.i18n import _
from heat.common import identifier
from heat.common import serializers
from heat.common import wsgi

View File

@ -22,6 +22,7 @@ from webob import exc
from heat.api.openstack.v1 import util
from heat.api.openstack.v1.views import stacks_view
from heat.common import environment_format
from heat.common.i18n import _
from heat.common.i18n import _LW
from heat.common import identifier
from heat.common import param_utils

View File

@ -21,6 +21,7 @@ import sys
from oslo.config import cfg
from heat.common.i18n import _
from heat.db import api
from heat.db import utils
from heat.openstack.common import log

View File

@ -19,6 +19,7 @@ from oslo.utils import importutils
from webob.exc import HTTPBadRequest
from webob.exc import HTTPUnauthorized
from heat.common.i18n import _
from heat.common import wsgi

View File

@ -20,6 +20,7 @@ import os
from eventlet.green import socket
from oslo.config import cfg
from heat.common.i18n import _
from heat.common import wsgi
from heat.openstack.common import log as logging

View File

@ -22,7 +22,7 @@ import logging
import webob.exc
from heat.openstack.common.gettextutils import _
from heat.common.i18n import _
from heat.openstack.common import local
from heat.rpc import client as rpc_client

View File

@ -11,6 +11,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from heat.common.i18n import _
from heat.common.template_format import yaml
from heat.common.template_format import yaml_loader

View File

@ -22,7 +22,7 @@ import sys
import six
from six.moves.urllib import parse as urlparse
from heat.openstack.common.gettextutils import _
from heat.common.i18n import _
from heat.openstack.common import log as logging

View File

@ -18,6 +18,8 @@
from oslo import i18n
from heat.openstack.common import gettextutils
_translators = i18n.TranslatorFactory(domain='heat')
@ -33,3 +35,13 @@ _LI = _translators.log_info
_LW = _translators.log_warning
_LE = _translators.log_error
_LC = _translators.log_critical
# FIXME(elynn): Parts in oslo-incubator are still using gettextutils._(), etc.,
# from oslo-incubator. Until these parts are changed to use oslo.i18n, we'll
# monkey-patch gettextutils._(), _LI(), etc., to use our oslo.i18n versions.
gettextutils._ = _
gettextutils._LI = _LI
gettextutils._LW = _LW
gettextutils._LE = _LE
gettextutils._LC = _LC
gettextutils.install = i18n.install

View File

@ -17,6 +17,8 @@ import re
from oslo.utils import encodeutils
from six.moves.urllib import parse as urlparse
from heat.common.i18n import _
class HeatIdentifier(collections.Mapping):

View File

@ -15,8 +15,9 @@
'''
Utility for fetching and running plug point implementation classes
'''
from heat.common.i18n import _
from heat.common.i18n import _LE
from heat.engine import resources
from heat.openstack.common.gettextutils import _LE
from heat.openstack.common import log as logging
LOG = logging.getLogger(__name__)

View File

@ -13,7 +13,7 @@
from oslo.utils import strutils
from heat.openstack.common.gettextutils import _
from heat.common.i18n import _
def extract_bool(subject):

View File

@ -21,6 +21,8 @@ import uuid
from six.moves import xrange
from heat.common.i18n import _
def _to_byte_string(value, num_bits):
"""Convert an integer to a big-endian string of bytes with padding.

View File

@ -19,7 +19,7 @@ from oslo.config import cfg
import yaml
from heat.common import exception
from heat.openstack.common.gettextutils import _
from heat.common.i18n import _
cfg.CONF.import_opt('max_template_size', 'heat.common.config')

View File

@ -18,6 +18,8 @@ Utilities for handling ISO 8601 duration format.
import random
import re
from heat.common.i18n import _
iso_duration_re = re.compile('PT(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?$')

View File

@ -34,6 +34,7 @@ from eventlet.green import ssl
import eventlet.greenio
import eventlet.wsgi
from oslo.config import cfg
from oslo import i18n
from oslo.utils import importutils
from paste import deploy
import routes
@ -44,8 +45,8 @@ import webob.exc
from heat.api.aws import exception as aws_exception
from heat.common import exception
from heat.common.i18n import _
from heat.common import serializers
from heat.openstack.common import gettextutils
URL_LENGTH_LIMIT = 50000
@ -521,7 +522,7 @@ class Request(webob.Request):
"""
if not self.accept_language:
return None
all_languages = gettextutils.get_available_languages('heat')
all_languages = i18n.get_available_languages('heat')
return self.accept_language.best_match(all_languages)
@ -735,9 +736,9 @@ def log_exception(err, exc_info):
def translate_exception(exc, locale):
"""Translates all translatable elements of the given exception."""
if isinstance(exc, exception.HeatException):
exc.message = gettextutils.translate(exc.message, locale)
exc.message = i18n.translate(exc.message, locale)
else:
exc.message = gettextutils.translate(six.text_type(exc), locale)
exc.message = i18n.translate(six.text_type(exc), locale)
if isinstance(exc, webob.exc.HTTPError):
# If the explanation is not a Message, that means that the
@ -746,13 +747,13 @@ def translate_exception(exc, locale):
# exception is converted to a response, let's actually swap it with
# message, since message is what gets passed in at construction time
# in the API
if not isinstance(exc.explanation, gettextutils.Message):
if not isinstance(exc.explanation, i18n._message.Message):
exc.explanation = six.text_type(exc)
exc.detail = ''
else:
exc.explanation = \
gettextutils.translate(exc.explanation, locale)
exc.detail = gettextutils.translate(exc.detail, locale)
i18n.translate(exc.explanation, locale)
exc.detail = i18n.translate(exc.detail, locale)
return exc

View File

@ -17,15 +17,10 @@ from __future__ import print_function
import sys
from oslo.config import cfg
from oslo import i18n
from heat.db import migration
from heat.openstack.common import log as logging
# fixme(elynn): Since install() is deprecated, we should remove it in
# the future
i18n.install('heat')
LOG = logging.getLogger(__name__)

View File

@ -14,6 +14,7 @@
import collections
import warnings
from heat.common.i18n import _
from heat.engine import constraints as constr
from heat.engine import support

View File

@ -19,6 +19,7 @@ import six
from heat.api.aws import utils as aws_utils
from heat.common import exception
from heat.common.i18n import _
from heat.engine import function
from heat.engine import resource

View File

@ -15,6 +15,7 @@
import collections
import six
from heat.common.i18n import _
from heat.engine.cfn import functions as cfn_funcs
from heat.engine import function
from heat.engine import parameters

View File

@ -28,6 +28,7 @@ import six
from six.moves.urllib import parse as urlparse
from heat.common import exception
from heat.common.i18n import _
from heat.engine.clients import client_plugin
from heat.engine import scheduler

View File

@ -19,6 +19,7 @@ from oslo.utils import strutils
import six
from heat.common import exception
from heat.common.i18n import _
from heat.engine import resources

View File

@ -14,6 +14,7 @@
import collections
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine.cfn import functions as cfn_funcs
from heat.engine import function

View File

@ -13,6 +13,7 @@
# under the License.
from heat.common import exception
from heat.common.i18n import _
from heat.engine import constraints as constr
from heat.engine import parameters

View File

@ -20,6 +20,7 @@ from oslo.utils import strutils
import six
from heat.common import exception
from heat.common.i18n import _
from heat.engine import constraints as constr

View File

@ -19,6 +19,7 @@ import sys
from oslo.config import cfg
import six
from heat.common.i18n import _
from heat.common import plugin_loader
from heat.openstack.common import log

View File

@ -16,6 +16,7 @@ import collections
import six
from heat.common import exception
from heat.common.i18n import _
from heat.engine import constraints as constr
from heat.engine import function
from heat.engine import parameters

View File

@ -19,6 +19,7 @@ import six
from heat.common import environment_format
from heat.common import exception
from heat.common.i18n import _
from heat.common import timeutils as iso8601utils
from heat.engine import attributes
from heat.engine import constraints

View File

@ -13,6 +13,7 @@
from heat.common import exception
from heat.common.i18n import _
from heat.engine import constraints
from heat.engine import properties
from heat.engine import resource

View File

@ -12,6 +12,7 @@
# under the License.
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import constraints

View File

@ -14,6 +14,7 @@
import six
from heat.common import exception
from heat.common.i18n import _
from heat.engine import constraints
from heat.engine import properties
from heat.engine import resource

View File

@ -14,6 +14,7 @@
from oslo.config import cfg
from heat.common import exception
from heat.common.i18n import _
from heat.engine import constraints
from heat.engine import properties
from heat.engine import resource

View File

@ -11,6 +11,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import properties
from heat.engine import resource

View File

@ -11,6 +11,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import constraints
from heat.engine import properties

View File

@ -11,6 +11,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import properties
from heat.engine.resources.neutron import neutron

View File

@ -12,6 +12,7 @@
# under the License.
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import constraints
from heat.engine import properties

View File

@ -11,6 +11,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import constraints
from heat.engine import properties

View File

@ -11,6 +11,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import properties
from heat.engine.resources.neutron import neutron

View File

@ -15,6 +15,7 @@
# limitations under the License.
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import constraints
from heat.engine import properties

View File

@ -14,6 +14,7 @@
import warnings
from heat.common import exception
from heat.common.i18n import _
from heat.engine import resource
from heat.engine import scheduler
from heat.openstack.common import log as logging

View File

@ -11,6 +11,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import constraints
from heat.engine import properties

View File

@ -12,6 +12,7 @@
# under the License.
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import constraints
from heat.engine import properties

View File

@ -12,6 +12,7 @@
# under the License.
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import properties
from heat.engine.resources.neutron import neutron

View File

@ -12,6 +12,7 @@
# under the License.
from heat.common import exception
from heat.common.i18n import _
from heat.engine import constraints
from heat.engine import properties
from heat.engine.resources.neutron import neutron

View File

@ -11,6 +11,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import constraints
from heat.engine import properties

View File

@ -11,6 +11,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import constraints
from heat.engine import properties

View File

@ -12,6 +12,7 @@
# under the License.
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import constraints
from heat.engine import properties

View File

@ -11,6 +11,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from heat.common.i18n import _
from heat.engine import properties
from heat.engine import resource
from heat.engine.resources.neutron import neutron

View File

@ -13,6 +13,7 @@
from six.moves.urllib import parse as urlparse
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import constraints
from heat.engine import properties

View File

@ -14,6 +14,7 @@
import six
from heat.common import exception
from heat.common.i18n import _
from heat.engine import properties
from heat.engine import resource

View File

@ -11,6 +11,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from heat.common.i18n import _
from heat.common.template_format import yaml
from heat.common.template_format import yaml_dumper
from heat.engine import properties

View File

@ -14,6 +14,7 @@
# under the License.
from heat.common import exception
from heat.common.i18n import _
from heat.engine import constraints as constr
from heat.engine import properties
from heat.engine import resource

View File

@ -18,6 +18,7 @@ import six
import uuid
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import constraints
from heat.engine import properties

View File

@ -17,6 +17,7 @@ import collections
import functools
import six
from heat.common.i18n import _
from heat.engine import properties
from heat.engine.resources.software_config import software_config as sc
from heat.engine.resources.software_config import software_deployment as sd

View File

@ -14,6 +14,7 @@
from requests import exceptions
from heat.common import exception
from heat.common.i18n import _
from heat.common import template_format
from heat.common import urlfetch
from heat.engine import attributes

View File

@ -11,6 +11,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import properties
from heat.engine import resource

View File

@ -13,6 +13,7 @@
from six.moves.urllib import parse as urlparse
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import properties
from heat.engine import resource

View File

@ -18,6 +18,7 @@ from requests import exceptions
import six
from heat.common import exception
from heat.common.i18n import _
from heat.common import template_format
from heat.common import urlfetch
from heat.engine import attributes

View File

@ -12,6 +12,7 @@
# under the License.
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import constraints
from heat.engine import properties

View File

@ -14,6 +14,7 @@
import json
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import constraints
from heat.engine import properties

View File

@ -12,6 +12,7 @@
# under the License.
from heat.common import exception
from heat.common.i18n import _
from heat.engine import constraints
from heat.engine import properties
from heat.engine import resource

View File

@ -15,6 +15,7 @@ import json
import uuid
from heat.common import exception
from heat.common.i18n import _
from heat.common import identifier
from heat.engine import attributes
from heat.engine import constraints

View File

@ -11,6 +11,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from heat.common.i18n import _
SUPPORT_STATUSES = (UNKNOWN, SUPPORTED, PROTOTYPE, DEPRECATED,
UNSUPPORTED) = ('UNKNOWN', 'SUPPORTED', 'PROTOTYPE',
'DEPRECATED', 'UNSUPPORTED')

View File

@ -19,6 +19,7 @@ import six
from stevedore import extension
from heat.common import exception
from heat.common.i18n import _
from heat.db import api as db_api
from heat.openstack.common import log as logging

View File

@ -32,6 +32,7 @@ import six
import stevedore.named
from heat.openstack.common import gettextutils
from heat.common import i18n
from heat.openstack.common import importutils
gettextutils.install('heat')

View File

@ -18,9 +18,6 @@ def fake_translate_msgid(msgid, domain, desired_locale=None):
return msgid
i18n.enable_lazy()
# fixme(elynn): Since install() is deprecated, we should remove it in
# the future
i18n.install('heat')
#To ensure messages don't really get translated while running tests.
#As there are lots of places where matching is expected when comparing

View File

@ -19,6 +19,7 @@ import fixtures
import six
from heat.common import exception
from heat.common.i18n import _
from heat.tests import common

View File

@ -21,6 +21,7 @@ from oslo.messaging._drivers import common as rpc_common
import heat.api.middleware.fault as fault
from heat.common import exception as heat_exc
from heat.common.i18n import _
from heat.tests.common import HeatTestCase

View File

@ -16,6 +16,7 @@ import six
import uuid
from heat.common import exception
from heat.common.i18n import _
from heat.engine.cfn import functions
from heat.engine import environment
from heat.engine import function

View File

@ -21,6 +21,7 @@ from neutronclient.neutron import v2_0 as neutronV20
from neutronclient.v2_0 import client as neutronclient
from heat.common import exception
from heat.common.i18n import _
from heat.common import template_format
from heat.engine.clients.os import nova
from heat.engine.resources.neutron import loadbalancer

View File

@ -20,6 +20,7 @@ import yaml
import mock
from heat.common import exception
from heat.common.i18n import _
from heat.common import template_format
from heat.common import urlfetch
from heat.engine import attributes

View File

@ -15,6 +15,7 @@ from glanceclient import exc as glance_exceptions
import six
from heat.common import exception
from heat.common.i18n import _
from heat.common import template_format
from heat.engine.clients.os import glance
from heat.engine.clients.os import nova

View File

@ -47,5 +47,4 @@ commands = python setup.py build_sphinx
# H803 no full stop at the end of the commit message
ignore = H302,H404,H803
show-source = true
builtins = _
exclude=.venv,.git,.tox,dist,*openstack/common*,*lib/python*,*egg,tools,build