diff --git a/heatclient/_i18n.py b/heatclient/_i18n.py new file mode 100644 index 00000000..1177be41 --- /dev/null +++ b/heatclient/_i18n.py @@ -0,0 +1,47 @@ +# 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. + +"""oslo.i18n integration module. + +See http://docs.openstack.org/developer/oslo.i18n/usage.html + +""" + +import oslo_i18n + +# NOTE(dhellmann): This reference to o-s-l-o will be replaced by the +# application name when this module is synced into the separate +# repository. It is OK to have more than one translation function +# using the same domain, since there will still only be one message +# catalog. +_translators = oslo_i18n.TranslatorFactory(domain='heatclient') + +# 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 + + +def get_available_languages(): + return oslo_i18n.get_available_languages('heatclient') + + +def enable_lazy(): + return oslo_i18n.enable_lazy() diff --git a/heatclient/common/deployment_utils.py b/heatclient/common/deployment_utils.py index ee209dc1..c44da2f3 100644 --- a/heatclient/common/deployment_utils.py +++ b/heatclient/common/deployment_utils.py @@ -18,8 +18,8 @@ from six.moves.urllib import parse as urlparse from swiftclient import client as sc from swiftclient import utils as swiftclient_utils +from heatclient._i18n import _ from heatclient import exc -from heatclient.openstack.common._i18n import _ from heatclient.v1 import software_configs diff --git a/heatclient/common/environment_format.py b/heatclient/common/environment_format.py index 8f2c4eaa..201ff60b 100644 --- a/heatclient/common/environment_format.py +++ b/heatclient/common/environment_format.py @@ -12,8 +12,8 @@ import yaml +from heatclient._i18n import _ from heatclient.common import template_format -from heatclient.openstack.common._i18n import _ SECTIONS = ( diff --git a/heatclient/common/event_utils.py b/heatclient/common/event_utils.py index c0bc42eb..9208d0c3 100644 --- a/heatclient/common/event_utils.py +++ b/heatclient/common/event_utils.py @@ -15,9 +15,9 @@ import sys import time +from heatclient._i18n import _ from heatclient.common import utils import heatclient.exc as exc -from heatclient.openstack.common._i18n import _ def get_hook_events(hc, stack_id, event_args, nested_depth=0, diff --git a/heatclient/common/hook_utils.py b/heatclient/common/hook_utils.py index 39fedb5b..66b980a6 100644 --- a/heatclient/common/hook_utils.py +++ b/heatclient/common/hook_utils.py @@ -14,9 +14,9 @@ import logging from oslo_utils import fnmatch -import heatclient.exc as exc -from heatclient.openstack.common._i18n import _ -from heatclient.openstack.common._i18n import _LE +from heatclient._i18n import _ +from heatclient._i18n import _LE +from heatclient import exc logger = logging.getLogger(__name__) diff --git a/heatclient/common/http.py b/heatclient/common/http.py index 3d05b911..0a31496d 100644 --- a/heatclient/common/http.py +++ b/heatclient/common/http.py @@ -27,10 +27,10 @@ import requests import six from six.moves.urllib import parse +from heatclient._i18n import _ +from heatclient._i18n import _LW from heatclient.common import utils from heatclient import exc -from heatclient.openstack.common._i18n import _ -from heatclient.openstack.common._i18n import _LW LOG = logging.getLogger(__name__) USER_AGENT = 'python-heatclient' diff --git a/heatclient/common/template_format.py b/heatclient/common/template_format.py index 9ba4d641..f73339f0 100644 --- a/heatclient/common/template_format.py +++ b/heatclient/common/template_format.py @@ -13,7 +13,7 @@ import json import yaml -from heatclient.openstack.common._i18n import _ +from heatclient._i18n import _ if hasattr(yaml, 'CSafeLoader'): yaml_loader = yaml.CSafeLoader diff --git a/heatclient/common/template_utils.py b/heatclient/common/template_utils.py index cf28aefb..c81da43d 100644 --- a/heatclient/common/template_utils.py +++ b/heatclient/common/template_utils.py @@ -20,11 +20,11 @@ from six.moves.urllib import error from six.moves.urllib import parse from six.moves.urllib import request +from heatclient._i18n import _ from heatclient.common import environment_format from heatclient.common import template_format from heatclient.common import utils from heatclient import exc -from heatclient.openstack.common._i18n import _ def process_template_path(template_path, object_request=None, existing=False): diff --git a/heatclient/common/utils.py b/heatclient/common/utils.py index f2b20f18..91410acd 100644 --- a/heatclient/common/utils.py +++ b/heatclient/common/utils.py @@ -29,9 +29,9 @@ from six.moves.urllib import parse from six.moves.urllib import request import yaml +from heatclient._i18n import _ +from heatclient._i18n import _LE from heatclient import exc -from heatclient.openstack.common._i18n import _ -from heatclient.openstack.common._i18n import _LE from heatclient.openstack.common import cliutils LOG = logging.getLogger(__name__) diff --git a/heatclient/exc.py b/heatclient/exc.py index 9fd5bef5..b5de2cc7 100644 --- a/heatclient/exc.py +++ b/heatclient/exc.py @@ -15,7 +15,7 @@ import sys from oslo_serialization import jsonutils from oslo_utils import reflection -from heatclient.openstack.common._i18n import _ +from heatclient._i18n import _ verbose = 0 diff --git a/heatclient/openstack/common/_i18n.py b/heatclient/openstack/common/_i18n.py deleted file mode 100644 index 3a8b7286..00000000 --- a/heatclient/openstack/common/_i18n.py +++ /dev/null @@ -1,45 +0,0 @@ -# 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. - -"""oslo.i18n integration module. - -See http://docs.openstack.org/developer/oslo.i18n/usage.html - -""" - -try: - import oslo_i18n - - # NOTE(dhellmann): This reference to o-s-l-o will be replaced by the - # application name when this module is synced into the separate - # repository. It is OK to have more than one translation function - # using the same domain, since there will still only be one message - # catalog. - _translators = oslo_i18n.TranslatorFactory(domain='heatclient') - - # 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 -except ImportError: - # NOTE(dims): Support for cases where a project wants to use - # code from oslo-incubator, but is not ready to be internationalized - # (like tempest) - _ = _LI = _LW = _LE = _LC = lambda x: x diff --git a/heatclient/openstack/common/apiclient/base.py b/heatclient/openstack/common/apiclient/base.py index 3e685286..b99f51bd 100644 --- a/heatclient/openstack/common/apiclient/base.py +++ b/heatclient/openstack/common/apiclient/base.py @@ -46,7 +46,7 @@ from oslo_utils import strutils import six from six.moves.urllib import parse -from heatclient.openstack.common._i18n import _, _LW +from heatclient._i18n import _, _LW from heatclient.openstack.common.apiclient import exceptions LOG = logging.getLogger(__name__) diff --git a/heatclient/openstack/common/apiclient/client.py b/heatclient/openstack/common/apiclient/client.py index 87337726..4fd52a28 100644 --- a/heatclient/openstack/common/apiclient/client.py +++ b/heatclient/openstack/common/apiclient/client.py @@ -38,7 +38,7 @@ from oslo_utils import encodeutils from oslo_utils import importutils import requests -from heatclient.openstack.common._i18n import _ +from heatclient._i18n import _ from heatclient.openstack.common.apiclient import exceptions _logger = logging.getLogger(__name__) diff --git a/heatclient/openstack/common/apiclient/exceptions.py b/heatclient/openstack/common/apiclient/exceptions.py index 247db55e..55e7cc32 100644 --- a/heatclient/openstack/common/apiclient/exceptions.py +++ b/heatclient/openstack/common/apiclient/exceptions.py @@ -38,7 +38,7 @@ import sys import six -from heatclient.openstack.common._i18n import _ +from heatclient._i18n import _ class ClientException(Exception): diff --git a/heatclient/openstack/common/apiclient/utils.py b/heatclient/openstack/common/apiclient/utils.py index 4307adc4..2c31c096 100644 --- a/heatclient/openstack/common/apiclient/utils.py +++ b/heatclient/openstack/common/apiclient/utils.py @@ -28,7 +28,7 @@ from oslo_utils import encodeutils from oslo_utils import uuidutils import six -from heatclient.openstack.common._i18n import _ +from heatclient._i18n import _ from heatclient.openstack.common.apiclient import exceptions diff --git a/heatclient/openstack/common/cliutils.py b/heatclient/openstack/common/cliutils.py index 391c7c40..8089a295 100644 --- a/heatclient/openstack/common/cliutils.py +++ b/heatclient/openstack/common/cliutils.py @@ -30,7 +30,7 @@ import prettytable import six from six import moves -from heatclient.openstack.common._i18n import _ +from heatclient._i18n import _ class MissingArgs(Exception): diff --git a/heatclient/osc/v1/event.py b/heatclient/osc/v1/event.py index 44bcc374..9cdf28ad 100644 --- a/heatclient/osc/v1/event.py +++ b/heatclient/osc/v1/event.py @@ -19,10 +19,10 @@ from cliff.formatters import base from osc_lib.command import command from osc_lib import utils +from heatclient._i18n import _ from heatclient.common import event_utils from heatclient.common import utils as heat_utils from heatclient import exc -from heatclient.openstack.common._i18n import _ class ShowEvent(command.ShowOne): diff --git a/heatclient/osc/v1/software_config.py b/heatclient/osc/v1/software_config.py index 7adccc84..af27be71 100644 --- a/heatclient/osc/v1/software_config.py +++ b/heatclient/osc/v1/software_config.py @@ -22,11 +22,11 @@ import six from six.moves.urllib import request import yaml +from heatclient._i18n import _ from heatclient.common import format_utils from heatclient.common import template_format from heatclient.common import utils as heat_utils from heatclient import exc as heat_exc -from heatclient.openstack.common._i18n import _ class DeleteConfig(command.Command): diff --git a/heatclient/osc/v1/software_deployment.py b/heatclient/osc/v1/software_deployment.py index 90c0cebe..37abcb46 100644 --- a/heatclient/osc/v1/software_deployment.py +++ b/heatclient/osc/v1/software_deployment.py @@ -20,11 +20,11 @@ from osc_lib import exceptions as exc from osc_lib import utils from oslo_serialization import jsonutils +from heatclient._i18n import _ from heatclient.common import deployment_utils from heatclient.common import format_utils from heatclient.common import utils as heat_utils from heatclient import exc as heat_exc -from heatclient.openstack.common._i18n import _ class CreateDeployment(format_utils.YamlFormat): diff --git a/heatclient/osc/v1/stack.py b/heatclient/osc/v1/stack.py index 5ecf8433..2dcb5790 100644 --- a/heatclient/osc/v1/stack.py +++ b/heatclient/osc/v1/stack.py @@ -24,6 +24,8 @@ from oslo_serialization import jsonutils import six from six.moves.urllib import request +from heatclient._i18n import _ +from heatclient._i18n import _LI from heatclient.common import event_utils from heatclient.common import format_utils from heatclient.common import hook_utils @@ -31,8 +33,6 @@ from heatclient.common import http from heatclient.common import template_utils from heatclient.common import utils as heat_utils from heatclient import exc as heat_exc -from heatclient.openstack.common._i18n import _ -from heatclient.openstack.common._i18n import _LI class CreateStack(command.ShowOne): diff --git a/heatclient/osc/v1/stack_failures.py b/heatclient/osc/v1/stack_failures.py index 257f1516..687f903d 100644 --- a/heatclient/osc/v1/stack_failures.py +++ b/heatclient/osc/v1/stack_failures.py @@ -16,9 +16,9 @@ import collections from osc_lib.command import command +from heatclient._i18n import _ from heatclient.common import format_utils from heatclient import exc -from heatclient.openstack.common._i18n import _ class ListStackFailures(command.Command): diff --git a/heatclient/osc/v1/template.py b/heatclient/osc/v1/template.py index 1b089dd7..154fc2ee 100644 --- a/heatclient/osc/v1/template.py +++ b/heatclient/osc/v1/template.py @@ -18,12 +18,12 @@ from osc_lib.command import command from osc_lib import utils import six +from heatclient._i18n import _ from heatclient.common import format_utils from heatclient.common import http from heatclient.common import template_utils from heatclient.common import utils as heat_utils from heatclient import exc -from heatclient.openstack.common._i18n import _ class VersionList(command.Lister): diff --git a/heatclient/shell.py b/heatclient/shell.py index 3b24c5cf..558fb8a8 100644 --- a/heatclient/shell.py +++ b/heatclient/shell.py @@ -27,10 +27,10 @@ from oslo_utils import importutils import six import heatclient +from heatclient._i18n import _ from heatclient import client as heat_client from heatclient.common import utils from heatclient import exc -from heatclient.openstack.common._i18n import _ logger = logging.getLogger(__name__) osprofiler_profiler = importutils.try_import("osprofiler.profiler") diff --git a/heatclient/v1/shell.py b/heatclient/v1/shell.py index 35a9102c..b605b72f 100644 --- a/heatclient/v1/shell.py +++ b/heatclient/v1/shell.py @@ -22,6 +22,9 @@ import six from six.moves.urllib import request import yaml +from heatclient._i18n import _ +from heatclient._i18n import _LI +from heatclient._i18n import _LW from heatclient.common import deployment_utils from heatclient.common import event_utils from heatclient.common import hook_utils @@ -30,9 +33,6 @@ from heatclient.common import template_format from heatclient.common import template_utils from heatclient.common import utils import heatclient.exc as exc -from heatclient.openstack.common._i18n import _ -from heatclient.openstack.common._i18n import _LI -from heatclient.openstack.common._i18n import _LW logger = logging.getLogger(__name__) diff --git a/heatclient/v1/stacks.py b/heatclient/v1/stacks.py index 864772f1..5b1c6b1e 100644 --- a/heatclient/v1/stacks.py +++ b/heatclient/v1/stacks.py @@ -16,9 +16,9 @@ import six from six.moves.urllib import parse +from heatclient._i18n import _ from heatclient.common import utils from heatclient import exc -from heatclient.openstack.common._i18n import _ from heatclient.openstack.common.apiclient import base diff --git a/tox.ini b/tox.ini index da1e493c..d0b8aed9 100644 --- a/tox.ini +++ b/tox.ini @@ -54,4 +54,4 @@ exclude=.venv,.git,.tox,dist,*openstack/common*,*lib/python*,*egg,build max-complexity=20 [hacking] -import_exceptions = heatclient.openstack.common._i18n +import_exceptions = heatclient._i18n