Adds local i18n

Adds local i18n and replaces the usage of
nova i18n with the local one. This way, there
is one fewer dependencies on nova.
This commit is contained in:
Claudiu Belu 2015-03-02 11:24:18 -08:00
parent 3c01c2704d
commit 38617f5fb2
22 changed files with 69 additions and 21 deletions

46
hyperv/i18n.py Normal file
View File

@ -0,0 +1,46 @@
# 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.
"""oslo.i18n integration module.
See http://docs.openstack.org/developer/oslo.i18n/usage.html .
"""
import oslo_i18n
DOMAIN = 'nova'
_translators = oslo_i18n.TranslatorFactory(domain=DOMAIN)
# 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 translate(value, user_locale):
return oslo_i18n.translate(value, user_locale)
def get_available_languages():
return oslo_i18n.get_available_languages(DOMAIN)

View File

@ -31,9 +31,10 @@ if sys.platform == 'win32':
from oslo_log import log as logging
from nova import block_device
from nova.i18n import _LI
from nova.virt import driver
from hyperv.i18n import _LI
LOG = logging.getLogger(__name__)

View File

@ -21,8 +21,8 @@ import platform
from oslo_log import log as logging
from nova.i18n import _
from nova.virt import driver
from hyperv.i18n import _
from hyperv.nova import hostops
from hyperv.nova import livemigrationops
from hyperv.nova import migrationops

View File

@ -29,7 +29,7 @@ from oslo_utils import units
from nova.compute import arch
from nova.compute import hv_type
from nova.compute import vm_mode
from nova.i18n import _
from hyperv.i18n import _
from hyperv.nova import constants
from hyperv.nova import utilsfactory

View File

@ -20,7 +20,7 @@ import sys
if sys.platform == 'win32':
import wmi
from nova.i18n import _
from hyperv.i18n import _
from hyperv.nova import constants

View File

@ -22,7 +22,7 @@ from oslo_log import log as logging
from oslo_utils import excutils
from oslo_utils import units
from nova.i18n import _
from hyperv.i18n import _
from nova import utils
from hyperv.nova import utilsfactory
from hyperv.nova import vmutils

View File

@ -19,7 +19,7 @@ import os
from eventlet import patcher
from oslo_log import log as logging
from nova.i18n import _LE
from hyperv.i18n import _LE
LOG = logging.getLogger(__name__)

View File

@ -22,8 +22,8 @@ from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import excutils
from nova.i18n import _
from nova.virt import configdrive
from hyperv.i18n import _
from hyperv.nova import imagecache
from hyperv.nova import utilsfactory
from hyperv.nova import vmops

View File

@ -21,7 +21,8 @@ if sys.platform == 'win32':
from oslo_log import log as logging
from nova import exception
from nova.i18n import _, _LE
from hyperv.i18n import _, _LE
from hyperv.nova import vmutils
from hyperv.nova import vmutilsv2
from hyperv.nova import volumeutilsv2

View File

@ -23,8 +23,8 @@ from oslo_utils import excutils
from oslo_utils import units
from nova import exception
from nova.i18n import _, _LE
from nova.virt import configdrive
from hyperv.i18n import _, _LE
from hyperv.nova import imagecache
from hyperv.nova import utilsfactory
from hyperv.nova import vmops

View File

@ -23,7 +23,7 @@ import uuid
if sys.platform == 'win32':
import wmi
from nova.i18n import _
from hyperv.i18n import _
from hyperv.nova import vmutils

View File

@ -24,7 +24,7 @@ import sys
if sys.platform == 'win32':
import wmi
from nova.i18n import _
from hyperv.i18n import _
from hyperv.nova import networkutils
from hyperv.nova import vmutils

View File

@ -23,8 +23,8 @@ if sys.platform == 'win32':
from oslo_config import cfg
from oslo_log import log as logging
from nova.i18n import _
from nova import utils
from hyperv.i18n import _
from hyperv.nova import constants
from hyperv.nova import vmutils

View File

@ -22,8 +22,8 @@ from oslo_config import cfg
from oslo_log import log as logging
from nova.compute import task_states
from nova.i18n import _LW
from nova.image import glance
from hyperv.i18n import _LW
from hyperv.nova import utilsfactory
CONF = cfg.CONF

View File

@ -16,7 +16,7 @@
from oslo_config import cfg
from oslo_log import log as logging
from nova.i18n import _
from hyperv.i18n import _
from hyperv.nova import hostutils
from hyperv.nova import livemigrationutils
from hyperv.nova import networkutils

View File

@ -31,7 +31,7 @@ if sys.platform == 'win32':
from xml.etree import ElementTree
from nova.i18n import _
from hyperv.i18n import _
from hyperv.nova import constants
from hyperv.nova import vmutils

View File

@ -28,7 +28,7 @@ from xml.etree import ElementTree
from oslo_utils import units
from nova.i18n import _
from hyperv.i18n import _
from hyperv.nova import constants
from hyperv.nova import vhdutils
from hyperv.nova import vmutils

View File

@ -32,12 +32,12 @@ from oslo_utils import uuidutils
from nova.api.metadata import base as instance_metadata
from nova import exception
from nova.i18n import _, _LI, _LE, _LW
from nova.openstack.common import fileutils
from nova.openstack.common import loopingcall
from nova import utils
from nova.virt import configdrive
from nova.virt import hardware
from hyperv.i18n import _, _LI, _LE, _LW
from hyperv.nova import constants
from hyperv.nova import imagecache
from hyperv.nova import ioutils

View File

@ -29,7 +29,7 @@ from oslo_config import cfg
from oslo_log import log as logging
from nova import exception
from nova.i18n import _, _LW
from hyperv.i18n import _, _LW
from hyperv.nova import constants
from hyperv.nova import hostutils

View File

@ -27,8 +27,8 @@ from oslo_log import log as logging
from oslo_utils import excutils
from nova import exception
from nova.i18n import _, _LE, _LW
from nova.virt import driver
from hyperv.i18n import _, _LE, _LW
from hyperv.nova import utilsfactory
from hyperv.nova import vmutils

View File

@ -29,8 +29,8 @@ import time
from oslo_config import cfg
from oslo_log import log as logging
from nova.i18n import _
from nova import utils
from hyperv.i18n import _
from hyperv.nova import basevolumeutils
from hyperv.nova import vmutils

View File

@ -27,7 +27,7 @@ if sys.platform == 'win32':
from oslo_config import cfg
from oslo_log import log as logging
from nova.i18n import _
from hyperv.i18n import _
from nova import utils
from hyperv.nova import basevolumeutils
from hyperv.nova import vmutils