diff --git a/ironicclient/common/i18n.py b/ironicclient/common/i18n.py index 90f289ae7..2561853a1 100644 --- a/ironicclient/common/i18n.py +++ b/ironicclient/common/i18n.py @@ -13,9 +13,13 @@ # License for the specific language governing permissions and limitations # under the License. -import oslo_i18n +try: + import oslo_i18n +except ImportError: + def _(msg): + return msg +else: + _translators = oslo_i18n.TranslatorFactory(domain='ironicclient') -_translators = oslo_i18n.TranslatorFactory(domain='ironicclient') - -# The primary translation function using the well-known name "_" -_ = _translators.primary + # The primary translation function using the well-known name "_" + _ = _translators.primary diff --git a/releasenotes/notes/oslo-i18n-optional-ff28821441a0807c.yaml b/releasenotes/notes/oslo-i18n-optional-ff28821441a0807c.yaml new file mode 100644 index 000000000..68eee8774 --- /dev/null +++ b/releasenotes/notes/oslo-i18n-optional-ff28821441a0807c.yaml @@ -0,0 +1,5 @@ +--- +upgrade: + - | + The dependency on ``oslo.i18n`` is now optional. If you would like messages + from ironicclient to be translated, you need to install it explicitly. diff --git a/requirements.txt b/requirements.txt index 412c047c8..b53d8cd69 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,7 +8,6 @@ jsonschema>=2.6.0 # MIT keystoneauth1>=3.4.0 # Apache-2.0 osc-lib>=1.10.0 # Apache-2.0 oslo.config>=5.2.0 # Apache-2.0 -oslo.i18n>=3.15.3 # Apache-2.0 oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0 oslo.utils>=3.33.0 # Apache-2.0 PyYAML>=3.12 # MIT