Gnumed.pycommon.gmI18N

Package Gnumed :: Package pycommon :: Module gmI18N |
[frames] | no frames]

# Module gmI18N

source code

    GNUmed client internationalization/localization.

    All i18n/l10n issues should be handled through this modules.

    Theory of operation:

    To activate proper locale settings and translation services you need to

    - import this module
    - call activate_locale()
    - call install_domain()

    The translating method gettext.gettext() will then be
    installed into the global (!) namespace as _(). Your own
    modules thus need not do _anything_ (not even import gmI18N)
    to have _() available to them for translating strings. You
    need to make sure, however, that gmI18N is imported in your
    main module before any of the modules using it. In order to
    resolve circular references involving modules that
    absolutely _have_ to be imported before this module you can
    explicitly import gmI18N into them at the very beginning.

    The text domain (i.e. the name of the message catalog file)
    is derived from the name of the main executing script unless
    explicitly passed to install_domain(). The language you
    want to translate to is derived from environment variables
    by the locale system unless explicitly passed to
    install_domain().

    This module searches for message catalog files in 3 main locations:

     - standard POSIX places (/usr/share/locale/ ...)
     - below "${YOURAPPNAME_DIR}/po/"
     - below "<directory of binary of your app>/../po/"

    For DOS/Windows I don't know of standard places so probably
    only the last option will work. I don't know a thing about
    classic Mac behaviour. New Macs are POSIX, of course.

    It will then try to install candidates and *verify* whether
    the translation works by checking for the translation of a
    tag within itself (this is similar to the self-compiling
    compiler inserting a backdoor into its self-compiled
    copies).

    If none of this works it will fall back to making _() a noop.

    @copyright: authors

Author: H. Herb <hherb@gnumed.net>, I. Haywood <i.haywood@ugrad.unimelb.edu.au>, K. Hilbert <Karsten.Hilbert@gmx.net>

License: GPL v2 or later (details at http://www.gnu.org)

Functions
activate_locale() Get system locale from environment. | source code
install_domain(domain=None, language=None, prefer_local_catalog=False) Install a text domain suitable for the main script. | source code
get_encoding() Try to get a sane encoding. | source code

Variables
| system_locale = ``'````'``
| system_locale_level = ``{``}``
| __orig_tag__ = ``u'``Translate this or i18n into <en_EN> will not` `...``
| __package__ = ``'``Gnumed.pycommon``'``

Imports: sys, os, regex, locale, gettext, logging, codecs

Function Details

### get_encoding() | source code
Try to get a sane encoding. On MaxOSX locale.setlocale(locale.LC_ALL, '') does not have the desired effect, so that locale.getlocale()[1] still returns None. So in that case try to fallback to locale.getpreferredencoding(). <sys.getdefaultencoding()> what Python itself uses to convert string <-> unicode when no other encoding was specified ascii by default can be set in site.py and sitecustomize.py <locale.getlocale()[1]> what the current locale is *actually* using as the encoding for text conversion <locale.getpreferredencoding()> what the current locale would *recommend* using as the encoding for text conversion

Variables Details

  ### __orig_tag__ Value:
      u'Translate this or i18n into <en_EN> will not work properly !'