gettext for openstack-common modules.
Usual usage in an openstack.common module:
from ironic.openstack.common.gettextutils import _
Bases: unicode
A Message object is a unicode object that can be translated.
Translation of Message is done explicitly using the translate() method. For all non-translation intents and purposes, a Message is simply unicode, and can be treated as such.
Bases: logging.handlers.MemoryHandler
Handler that translates records before logging them.
The TranslationHandler takes a locale and a target logging.Handler object to forward LogRecord objects to after translating them. This handler depends on Message objects being logged, instead of regular strings.
The handler can be configured declaratively in the logging.conf as follows:
[handlers] keys = translatedlog, translator
[handler_translatedlog] class = handlers.WatchedFileHandler args = (‘/var/log/api-localized.log’,) formatter = context
[handler_translator] class = openstack.common.log.TranslationHandler target = translatedlog args = (‘zh_CN’,)
If the specified locale is not available in the system, the handler will log in the default locale.