universal python library for internalization and translation
Question: I need to internationalize and translate python application. I look forward
for some dictionary collection resides in additional resource files that could
be switched runtime and used smoothly inside python code.

I've searched stackoverflow.com for similar tools but find only platform-
specific libraries, e.g. for pylons, for django and so on.

Is there any general ready for use library?


Answer: Python's standard `gettext` module provides this. See the Python docs
[here](http://docs.python.org/2/library/gettext.html).

> The gettext module provides internationalization (I18N) and localization
> (L10N) services for your Python modules and applications. It supports both
> the GNU gettext message catalog API and a higher level, class-based API that
> may be more appropriate for Python files. The interface described below
> allows you to write your module and application messages in one natural
> language, and provide a catalog of translated messages for running under
> different natural languages.

A simple example:

    
    
    import gettext
    gettext.bindtextdomain('myapplication', '/path/to/my/language/directory')
    gettext.textdomain('myapplication')
    _ = gettext.gettext
    # ...
    print _('This is a translatable string.')
    

