update i18n guide for nova

This reflects the new approach of not translating log messages

Change-Id: Ie402c697a76a78db039a05ee03c60381ba37d91e
This commit is contained in:
Sean Dague 2017-03-20 10:36:07 -04:00
parent 6f66119153
commit e580afa839

View File

@ -10,22 +10,18 @@ appropriate language in different locales.
Nova exposes the oslo.i18n library support via the ``nova/i18n.py`` integration Nova exposes the oslo.i18n library support via the ``nova/i18n.py`` integration
module. This module provides the functions needed to wrap translatable strings. module. This module provides the functions needed to wrap translatable strings.
It provides the ``_()`` wrapper for general user-facing messages and specific It provides the ``_()`` wrapper for general user-facing messages (such
wrappers for messages used only for logging. DEBUG level messages do not need as ones that end up in command line responses, or responses over the
translation but CRITICAL, ERROR, WARNING and INFO messages should be wrapped network).
with ``_LC()``, ``_LE()``, ``_LW()`` or ``_LI()`` respectively.
For example:: One upon a time there was an effort to translate log messages in
OpenStack projects. But starting with the Ocata release these are no
LOG.debug("block_device_mapping %(mapping)s", longer being supported. Log messages **should not** be translated. Any
{'mapping': block_device_mapping}) use of ``_LI()``, ``_LW()``, ``_LE()``, ``_LC()`` are vestigial and
will be removed over time. No new uses of these should be added.
or::
LOG.warning(_LW('Unknown base file %(img)s'), {'img': img})
You should use the basic wrapper ``_()`` for strings which are not log You should use the basic wrapper ``_()`` for strings which are not log
messages:: messages that are expected to get to an end user::
raise nova.SomeException(_('Invalid service catalogue')) raise nova.SomeException(_('Invalid service catalogue'))
@ -38,12 +34,6 @@ Do not use ``locals()`` for formatting messages because:
If you do not follow the project conventions, your code may cause hacking If you do not follow the project conventions, your code may cause hacking
checks to fail. checks to fail.
The ``_()``, ``_LC()``, ``_LE()``, ``_LW()`` and ``_LI()`` functions can be The ``_()`` function can be imported with ::
imported with::
from nova.i18n import _ from nova.i18n import _
from nova.i18n import _LC
from nova.i18n import _LE
from nova.i18n import _LW
from nova.i18n import _LI