Switch over oslo.i18n

oslo.i18n has recently been released. This patch switches marconi over
oslo.i18n. As per oslo.i18n's instructions, a new i18n module has been
added under marconi. This module defines the translation globals and
imports the necessary functions from oslo.i18n.

The patch doesn't change the way Marconi does translation, this means
that a `_` function is still being injected to the builtins.

Note that the gettextutils module is still a required module from
oslo-inc because there are oslo-inc modules that depend on the old
gettextutils module.

Closes-bug: #1314300

Change-Id: Ifb8f3296d1a0e2483ebd1c8d868b7359ecc99fb5
This commit is contained in:
Flavio Percoco 2014-07-08 18:02:41 +02:00
parent e4a2757145
commit ef9d5247e9
26 changed files with 56 additions and 23 deletions

View File

@ -17,7 +17,7 @@ import jsonschema
from jsonschema import validators
from marconi.common import errors
from marconi.openstack.common.gettextutils import _
from marconi.i18n import _
from marconi.openstack.common import log
LOG = log.getLogger(__name__)

View File

@ -16,7 +16,7 @@ from __future__ import print_function
import functools
import sys
from marconi.openstack.common.gettextutils import _
from marconi.i18n import _
from marconi.openstack.common import log as logging

View File

@ -34,7 +34,7 @@ import contextlib
import six
from marconi.common import decorators
from marconi.openstack.common.gettextutils import _
from marconi.i18n import _
import marconi.openstack.common.log as logging
LOG = logging.getLogger(__name__)

View File

@ -18,7 +18,7 @@
import falcon
import six
from marconi.openstack.common.gettextutils import _
from marconi.i18n import _
import marconi.openstack.common.log as logging
from marconi.queues.transport import validation

31
marconi/i18n.py Normal file
View File

@ -0,0 +1,31 @@
# Copyright 2014 Red Hat, Inc.
# 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.
from oslo.i18n import * # noqa
_translators = TranslatorFactory(domain='marconi')
# 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

View File

@ -28,7 +28,7 @@ from bson import objectid
import pymongo.errors
import pymongo.read_preferences
from marconi.openstack.common.gettextutils import _
from marconi.i18n import _
import marconi.openstack.common.log as logging
from marconi.openstack.common import timeutils
from marconi.queues import storage

View File

@ -24,7 +24,7 @@ Field Mappings:
import pymongo.errors
from marconi.common import decorators
from marconi.openstack.common.gettextutils import _
from marconi.i18n import _
import marconi.openstack.common.log as logging
from marconi.openstack.common import timeutils
from marconi.queues import storage

View File

@ -26,7 +26,7 @@ from bson import objectid
from bson import tz_util
from pymongo import errors
from marconi.openstack.common.gettextutils import _
from marconi.i18n import _
import marconi.openstack.common.log as logging
from marconi.openstack.common import timeutils
from marconi.queues.storage import errors as storage_errors

View File

@ -17,7 +17,7 @@ from stevedore import driver
from marconi import common
from marconi.common import decorators
from marconi.openstack.common.gettextutils import _
from marconi.i18n import _
from marconi.openstack.common import log as logging
from marconi.queues.storage import base

View File

@ -17,7 +17,7 @@ import re
from oslo.config import cfg
from marconi.openstack.common.gettextutils import _
from marconi.i18n import _
MIN_MESSAGE_TTL = 60
MIN_CLAIM_TTL = 60

View File

@ -21,7 +21,7 @@ from oslo.config import cfg
from marconi.common import decorators
from marconi.common.transport.wsgi import helpers
from marconi.openstack.common.gettextutils import _
from marconi.i18n import _
import marconi.openstack.common.log as logging
from marconi.queues import transport
from marconi.queues.transport import auth

View File

@ -15,7 +15,7 @@
import falcon
from marconi.openstack.common.gettextutils import _
from marconi.i18n import _
class HTTPServiceUnavailable(falcon.HTTPServiceUnavailable):

View File

@ -14,7 +14,7 @@
import uuid
from marconi.openstack.common.gettextutils import _
from marconi.i18n import _
import marconi.openstack.common.log as logging
from marconi.queues.transport import utils
from marconi.queues.transport.wsgi import errors

View File

@ -16,7 +16,7 @@
import falcon
import six
from marconi.openstack.common.gettextutils import _
from marconi.i18n import _
import marconi.openstack.common.log as logging
from marconi.queues.storage import errors as storage_errors
from marconi.queues.transport import utils

View File

@ -16,7 +16,7 @@
import falcon
import six
from marconi.openstack.common.gettextutils import _
from marconi.i18n import _
import marconi.openstack.common.log as logging
from marconi.queues.storage import errors as storage_errors
from marconi.queues.transport import utils

View File

@ -16,7 +16,7 @@
import falcon
import six
from marconi.openstack.common.gettextutils import _
from marconi.i18n import _
import marconi.openstack.common.log as logging
from marconi.queues.storage import errors as storage_errors
from marconi.queues.transport import utils

View File

@ -16,7 +16,7 @@
import falcon
import six
from marconi.openstack.common.gettextutils import _
from marconi.i18n import _
import marconi.openstack.common.log as logging
from marconi.queues.transport import utils
from marconi.queues.transport import validation

View File

@ -15,7 +15,7 @@
import falcon
from marconi.openstack.common.gettextutils import _
from marconi.i18n import _
import marconi.openstack.common.log as logging
from marconi.queues.storage import errors as storage_errors
from marconi.queues.transport import utils

View File

@ -16,7 +16,7 @@
import falcon
import six
from marconi.openstack.common.gettextutils import _
from marconi.i18n import _
import marconi.openstack.common.log as logging
from marconi.queues.storage import errors as storage_errors
from marconi.queues.transport import utils

View File

@ -16,7 +16,7 @@
import falcon
import six
from marconi.openstack.common.gettextutils import _
from marconi.i18n import _
import marconi.openstack.common.log as logging
from marconi.queues.storage import errors as storage_errors
from marconi.queues.transport import utils

View File

@ -16,7 +16,7 @@
import falcon
import six
from marconi.openstack.common.gettextutils import _
from marconi.i18n import _
import marconi.openstack.common.log as logging
from marconi.queues.storage import errors as storage_errors
from marconi.queues.transport import utils

View File

@ -16,7 +16,7 @@
import falcon
import six
from marconi.openstack.common.gettextutils import _
from marconi.i18n import _
import marconi.openstack.common.log as logging
from marconi.queues.transport import utils
from marconi.queues.transport import validation

View File

@ -15,7 +15,7 @@
import falcon
from marconi.openstack.common.gettextutils import _
from marconi.i18n import _
import marconi.openstack.common.log as logging
from marconi.queues.storage import errors as storage_errors
from marconi.queues.transport import utils

View File

@ -15,4 +15,5 @@ WebOb>=1.2.3
stevedore>=0.14
six>=1.7.0
oslo.config>=1.2.1
oslo.i18n>=0.1.0
SQLAlchemy>=0.7.8,!=0.9.5,<=0.9.99

View File

@ -14,4 +14,5 @@ WebOb>=1.2.3
stevedore>=0.14
six>=1.7.0
oslo.config>=1.2.1
oslo.i18n>=0.1.0
SQLAlchemy>=0.7.8,!=0.9.5,<=0.9.99

View File

@ -52,5 +52,5 @@ commands = python setup.py build_sphinx
exclude = .venv*,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*.egg,.update-venv
[hacking]
import_exceptions = marconi.openstack.common.gettextutils._
import_exceptions = marconi.openstack.common.gettextutils._,marconi.i18n._