def install(domain, localedir):
'''
:param domain: translation domain
:param localedir: locale directory
Installs the function _() in Python’s builtin namespace, based on
domain and localedir. Codeset is always UTF-8.
As seen below, you usually mark the strings in your application that are
candidates for translation, by wrapping them in a call to the _() function,
like this:
.. sourcecode:: python
import elib.intl
elib.intl.install('myapplication', '/path/to/usr/share/locale')
print _('This string will be translated.')
Note that this is only one way, albeit the most convenient way,
to make the _() function available to your application. Because it affects
the entire application globally, and specifically Python’s built-in
namespace, localized modules should never install _(). Instead, you should
use :func:`elib.intl.install_module` to make _() available to your module.
'''
_install(domain, localedir, True)
gettext.install(domain, localedir, unicode=True)
评论列表
文章目录