But that causes problems for Python apps that use the module. For example, duplicity ran into a problem where it uses gettext.install, only to be later overridden by ubuntu_sso's gettext.install. It's not suitable for a Python module to attempt to own Python builtins like _().
This can be reproduced like so:
> import gettext
> gettext.install('duplicity')
> print(_)
<bound method NullTranslations.gettext of <gettext.NullTranslations instance at 0xb743ceac>>
> import ubuntu_sso.credentials
> print(_)
<bound method NullTranslations.ugettext of <gettext.NullTranslations instance at 0xb6d4cc0c>>
You see how it's changed to ugettext instead of gettext? And it's switched default domains.
A more suitable thing for ubuntu_sso to do is something like:
t = gettext.translation('ubuntu-sso-client')
_ = t.ugettext
In utils/ui.py, the following lines are used:
INSTALL_KWARGS = {} KWARGS[ "unicode" ] = True install( 'ubuntu- sso-client' , **INSTALL_KWARGS)
if sys.version_info < (3,):
INSTALL_
gettext.
But that causes problems for Python apps that use the module. For example, duplicity ran into a problem where it uses gettext.install, only to be later overridden by ubuntu_sso's gettext.install. It's not suitable for a Python module to attempt to own Python builtins like _().
This can be reproduced like so: install( 'duplicity' ) s.gettext of <gettext. NullTranslation s instance at 0xb743ceac>> sso.credentials s.ugettext of <gettext. NullTranslation s instance at 0xb6d4cc0c>>
> import gettext
> gettext.
> print(_)
<bound method NullTranslation
> import ubuntu_
> print(_)
<bound method NullTranslation
You see how it's changed to ugettext instead of gettext? And it's switched default domains.
A more suitable thing for ubuntu_sso to do is something like:
t = gettext. translation( 'ubuntu- sso-client' )
_ = t.ugettext
This is what the gettext documentation recommends for modules (http:// docs.python. org/library/ gettext. html#gettext. NullTranslation s.install).