Merge "Make oslo.i18n an optional dependency"

This commit is contained in:
Zuul 2020-04-06 12:28:33 +00:00 committed by Gerrit Code Review
commit c9d3ef2c21
6 changed files with 24 additions and 7 deletions

View File

@ -14,10 +14,10 @@
import sys
from oslo_config import cfg
import oslo_i18n as i18n
from oslo_log import log
from ironic.api import app
from ironic.common import i18n
from ironic.common import service

View File

@ -25,6 +25,6 @@ import eventlet
eventlet.monkey_patch(os=False)
import oslo_i18n as i18n # noqa for I202 due to 'import eventlet' above
from ironic.common import i18n # noqa for I202 due to 'import eventlet' above
i18n.install('ironic')

View File

@ -19,9 +19,20 @@ See https://docs.openstack.org/oslo.i18n/latest/user/
"""
import oslo_i18n as i18n
try:
import oslo_i18n as i18n
except ImportError:
def _(msg):
return msg
_translators = i18n.TranslatorFactory(domain='ironic')
def install(domain):
# NOTE(dtantsur): this is called before logging is initialized, so we
# cannot really log a warning here.
pass
else:
_translators = i18n.TranslatorFactory(domain='ironic')
# The primary translation function using the well-known name "_"
_ = _translators.primary
# The primary translation function using the well-known name "_"
_ = _translators.primary
install = i18n.install

View File

@ -0,0 +1,5 @@
---
upgrade:
- |
The dependency on ``oslo.i18n`` is now optional. If you would like messages
from ironic to be translated, you need to install it explicitly.

View File

@ -21,7 +21,6 @@ oslo.config>=5.2.0 # Apache-2.0
oslo.context>=2.19.2 # Apache-2.0
oslo.db>=4.40.0 # Apache-2.0
oslo.rootwrap>=5.8.0 # Apache-2.0
oslo.i18n>=3.15.3 # Apache-2.0
oslo.log>=3.36.0 # Apache-2.0
oslo.middleware>=3.31.0 # Apache-2.0
oslo.policy>=1.30.0 # Apache-2.0

View File

@ -200,3 +200,5 @@ universal = 1
[extras]
guru_meditation_reports =
oslo.reports>=1.18.0 # Apache-2.0
i18n =
oslo.i18n>=3.15.3 # Apache-2.0