Mercurial > getan > getan
comparison 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 |
comparison
equal
deleted
inserted
replaced
35:cfa9e755a5d2 | 36:e6f81aa329b1 |
---|---|
5 # | 5 # |
6 # This is Free Software licensed under the terms of GPLv3 or later. | 6 # This is Free Software licensed under the terms of GPLv3 or later. |
7 # For details see LICENSE coming with the source of 'getan'. | 7 # For details see LICENSE coming with the source of 'getan'. |
8 # | 8 # |
9 | 9 |
10 import locale | |
10 import logging | 11 import logging |
12 import os | |
11 | 13 |
12 logger = None | 14 logger = None |
13 | 15 |
14 def initialize(): | 16 def initialize(): |
17 setup_logging() | |
18 setup_locale() | |
19 | |
20 | |
21 def setup_logging(): | |
15 logging.basicConfig(level=logging.INFO, | 22 logging.basicConfig(level=logging.INFO, |
16 format='%(asctime)s %(levelname)s %(message)s', | 23 format='%(asctime)s %(levelname)s %(message)s', |
17 filename='getan.log', | 24 filename='getan.log', |
18 filemode='w') | 25 filemode='w') |
19 logger = logging.getLogger() | 26 logger = logging.getLogger() |
27 | |
28 | |
29 def setup_locale(): | |
30 for var in ('LANGUAGE', 'LC_ALL', 'LC_MESSAGES', 'LANG'): | |
31 if var in os.environ: | |
32 break | |
33 else: | |
34 default_locale = locale.getdefaultlocale() | |
35 # The default is normally a tuple of two strings. It may | |
36 # contain None, objects under some circumstances, though. | |
37 if len(default_locale) > 1: | |
38 lang = default_locale[0] | |
39 if isinstance(lang, str): | |
40 os.environ["LANG"] = lang | |
41 |