Mercurial > getan > getan
diff 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 diff
--- a/getan/config.py Sun Sep 05 15:54:44 2010 +0200 +++ b/getan/config.py Sat Oct 02 22:22:35 2010 +0200 @@ -7,13 +7,35 @@ # 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 +