Switch to internal _i18n pattern, as per oslo_i18n guidelines

Guidelines referenced from:
http://docs.openstack.org/developer/oslo.i18n/usage.html

Change-Id: I2135ebe5faf4b9d3853f634722a885f8ee5a90d5
Partially-Closes-Bug: #1519493
This commit is contained in:
Bo Chi 2015-11-26 21:55:21 -05:00 committed by Doug Wiegley
parent 8e287b7d38
commit c4f3e32e4a
11 changed files with 54 additions and 10 deletions

42
neutron_vpnaas/_i18n.py Normal file
View File

@ -0,0 +1,42 @@
# 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.
import oslo_i18n
DOMAIN = "neutron-vpnaas"
_translators = oslo_i18n.TranslatorFactory(domain=DOMAIN)
# The primary translation function using the well-known name "_"
_ = _translators.primary
# The contextual translation function using the name "_C"
_C = _translators.contextual_form
# The plural translation function using the name "_P"
_P = _translators.plural_form
# 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(DOMAIN)

View File

@ -22,7 +22,6 @@ from neutron.db import common_db_mixin as base_db
from neutron.db import l3_agentschedulers_db as l3_agent_db
from neutron.db import models_v2
from neutron.extensions import l3 as l3_exception
from neutron.i18n import _LW
from neutron import manager
from neutron.plugins.common import constants as p_constants
from neutron.plugins.common import utils
@ -32,6 +31,7 @@ from oslo_utils import uuidutils
import sqlalchemy as sa
from sqlalchemy.orm import exc
from neutron_vpnaas._i18n import _LW
from neutron_vpnaas.db.vpn import vpn_models
from neutron_vpnaas.db.vpn import vpn_validator
from neutron_vpnaas.extensions import vpnaas

View File

@ -20,12 +20,13 @@ import sys
from eventlet.green import subprocess
from neutron.common import config
from neutron.common import utils
from neutron.i18n import _LE, _LI
from oslo_config import cfg
from oslo_log import log as logging
from oslo_rootwrap import wrapper
import six
from neutron_vpnaas._i18n import _LE, _LI
if six.PY3:
import configparser as ConfigParser
else:

View File

@ -15,12 +15,13 @@
import time
import netaddr
from neutron.i18n import _LE, _LW
from oslo_log import log as logging
from oslo_serialization import jsonutils
import requests
from requests import exceptions as r_exc
from neutron_vpnaas._i18n import _LE, _LW
TIMEOUT = 20.0

View File

@ -18,7 +18,6 @@ import requests
from neutron.common import exceptions
from neutron.common import rpc as n_rpc
from neutron import context as ctx
from neutron.i18n import _LE, _LI, _LW
from neutron.plugins.common import constants
from neutron.plugins.common import utils as plugin_utils
from oslo_concurrency import lockutils
@ -27,6 +26,7 @@ from oslo_log import log as logging
import oslo_messaging
from oslo_service import loopingcall
from neutron_vpnaas._i18n import _LE, _LI, _LW
from neutron_vpnaas.services.vpn.common import topics
from neutron_vpnaas.services.vpn import device_drivers
from neutron_vpnaas.services.vpn.device_drivers import (

View File

@ -28,7 +28,6 @@ from neutron.api.v2 import attributes
from neutron.common import rpc as n_rpc
from neutron.common import utils as n_utils
from neutron import context
from neutron.i18n import _LE, _LI, _LW
from neutron.plugins.common import constants
from neutron.plugins.common import utils as plugin_utils
from oslo_concurrency import lockutils
@ -37,6 +36,7 @@ from oslo_log import log as logging
import oslo_messaging
from oslo_service import loopingcall
from neutron_vpnaas._i18n import _LE, _LI, _LW
from neutron_vpnaas.extensions import vpnaas
from neutron_vpnaas.services.vpn.common import topics
from neutron_vpnaas.services.vpn import device_drivers

View File

@ -21,7 +21,6 @@ from networking_brocade.vyatta.common import vrouter_config
from networking_brocade.vyatta.vpn import config as vyatta_vpn_config
from neutron.common import rpc as n_rpc
from neutron import context as n_ctx
from neutron.i18n import _LE, _LW
from oslo_config import cfg
from oslo_log import log as logging
import oslo_messaging as messaging
@ -29,6 +28,7 @@ from oslo_service import loopingcall
from oslo_service import periodic_task
import six
from neutron_vpnaas._i18n import _LE, _LW
from neutron_vpnaas.services.vpn.common import topics
from neutron_vpnaas.services.vpn import device_drivers

View File

@ -15,12 +15,12 @@
# under the License.
from neutron.db import servicetype_db as st_db
from neutron.i18n import _LI
from neutron.plugins.common import constants
from neutron.services import provider_configuration as pconf
from neutron.services import service_base
from oslo_log import log as logging
from neutron_vpnaas._i18n import _LI
from neutron_vpnaas.db.vpn import vpn_db
LOG = logging.getLogger(__name__)

View File

@ -14,12 +14,12 @@
from neutron.common import exceptions
from neutron.db import model_base
from neutron.i18n import _LI
from oslo_db import exception as db_exc
from oslo_log import log as logging
import sqlalchemy as sa
from sqlalchemy.orm import exc as sql_exc
from neutron_vpnaas._i18n import _LI
from neutron_vpnaas.db.vpn import vpn_models
LOG = logging.getLogger(__name__)

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron.i18n import _LI
from neutron_vpnaas._i18n import _LI
from rally.common import log as logging
from rally.task import scenario

View File

@ -107,5 +107,5 @@ builtins = _
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools,.ropeproject,rally-scenarios
[hacking]
import_exceptions = neutron.i18n
import_exceptions = neutron_vpnaas._i18n
local-check-factory = neutron.hacking.checks.factory