The openstack_dashboard.openstack.common.gettextutils ModuleΒΆ

gettext for openstack-common modules.

Usual usage in an openstack.common module:

from openstack_dashboard.openstack.common.gettextutils import _
class openstack_dashboard.openstack.common.gettextutils.LocaleHandler(locale, target)[source]

Bases: logging.Handler

Handler that can have a locale associated to translate Messages.

A quick example of how to utilize the Message class above. LocaleHandler takes a locale and a target logging.Handler object to forward LogRecord objects to after translating the internal Message.

LocaleHandler.emit(record)[source]
class openstack_dashboard.openstack.common.gettextutils.Message(msg, domain)[source]

Bases: UserString.UserString, object

Class used to encapsulate translatable messages.

Message.data[source]
openstack_dashboard.openstack.common.gettextutils.get_lazy_gettext(domain)[source]

Assemble and return a lazy gettext function for a given domain.

Factory method for a project/module to get a lazy gettext function for its own translation domain (i.e. nova, glance, cinder, etc.)

openstack_dashboard.openstack.common.gettextutils.install(domain)[source]

Install a _() function using the given translation domain.

Given a translation domain, install a _() function using gettext’s install() function.

The main difference from gettext.install() is that we allow overriding the default localedir (e.g. /usr/share/locale) using a translation-domain-specific environment variable (e.g. NOVA_LOCALEDIR).

Previous topic

The openstack_dashboard.openstack.common.policy Module

Next topic

The openstack_dashboard.openstack.common.eventlet_backdoor Module

This Page