gettext for openstack-common modules.
Usual usage in an openstack.common module:
from cinder.openstack.common.gettextutils import _
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.
Bases: UserString.UserString, object
Class used to encapsulate translatable messages.
Convenience function for configuring _() to use lazy gettext
Call this at the start of execution to enable the gettextutils._ function to use lazy gettext functionality. This is useful if your project is importing _ directly instead of using the gettextutils.install() way of importing the _ function.
Lists the available languages for the given translation domain.
Parameters: | domain – the domain to get languages for |
---|
Gets a localized version of the given message in the given locale.
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).
Parameters: |
|
---|