keystone/keystone/i18n.py
Shengjing Zhu 6abd44500f Fix translated response
When request has ``Accept-Language`` header, keystone should response
the translated message. Without oslo_i18n lazy translation feature, the
message will be translated before the server knows the language.

Actually this has been fixed previously, like
2167e3612c

But seems the logic was broken after i18n refactor.

Change-Id: Icb3d9dcd25a5dde0676fc4bd4eaad7b265a0c99d
2019-08-19 14:49:37 +08:00

30 lines
878 B
Python

# 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 https://docs.openstack.org/oslo.i18n/latest/user/usage.html .
"""
import oslo_i18n
oslo_i18n.enable_lazy()
_translators = oslo_i18n.TranslatorFactory(domain='keystone')
# The primary translation function using the well-known name "_"
_ = _translators.primary