view getan/config.py @ 36:e6f81aa329b1

Introduced i18n support; german and english translation available.
author Ingo Weinzierl <ingo_weinzierl@web.de>
date Sat, 02 Oct 2010 22:22:35 +0200
parents 9c4e8ba3c4fa
children d4ce02a33acd
line wrap: on
line source
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# (c) 2010 by Ingo Weinzierl <ingo.weinzierl@intevation.de>
#
# This is Free Software licensed under the terms of GPLv3 or later.
# For details see LICENSE coming with the source of 'getan'.
#

import locale
import logging
import os

logger = None

def initialize():
    setup_logging()
    setup_locale()


def setup_logging():
    logging.basicConfig(level=logging.INFO,
                        format='%(asctime)s %(levelname)s %(message)s',
                        filename='getan.log',
                        filemode='w')
    logger = logging.getLogger()


def setup_locale():
    for var in ('LANGUAGE', 'LC_ALL', 'LC_MESSAGES', 'LANG'):
        if var in os.environ:
            break
    else:
        default_locale = locale.getdefaultlocale()
        # The default is normally a tuple of two strings.  It may
        # contain None, objects under some circumstances, though.
        if len(default_locale) > 1:
            lang = default_locale[0]
            if isinstance(lang, str):
                os.environ["LANG"] = lang
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)