comparison jabberbot/i18n.py @ 2504:c27ee67397f0

Make pylint happy where it made sense, fix a few minor bugs.
author Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
date Sun, 22 Jul 2007 05:33:02 +0200
parents 754e3eedb9e5
children af857f8c2e44
comparison
equal deleted inserted replaced
2502:d9aef892fda8 2504:c27ee67397f0
5 @copyright: 2007 by Karol Nowak <grywacz@gmail.com> 5 @copyright: 2007 by Karol Nowak <grywacz@gmail.com>
6 @license: GNU GPL, see COPYING for details. 6 @license: GNU GPL, see COPYING for details.
7 """ 7 """
8 import logging, xmlrpclib 8 import logging, xmlrpclib
9 9
10 translations = None 10 TRANSLATIONS = None
11 11
12 12
13 def getText(original, lang="en"): 13 def get_text(original, lang="en"):
14 """ Return a translation of text in the user's language. 14 """ Return a translation of text in the user's language.
15 15
16 @type original: unicode 16 @type original: unicode
17 """ 17 """
18 if original == u"": 18 if original == u"":
19 return u"" 19 return u""
20 20
21 global translations 21 global TRANSLATIONS
22 if not translations: 22 if not TRANSLATIONS:
23 init_i18n() 23 init_i18n()
24 24
25 try: 25 try:
26 return translations[lang][original] 26 return TRANSLATIONS[lang][original]
27 except KeyError: 27 except KeyError:
28 return original 28 return original
29 29
30 30
31 def init_i18n(config): 31 def init_i18n(config):
32 """Prepare i18n 32 """Prepare i18n
33 33
34 @type config: jabberbot.config.BotConfig 34 @type config: jabberbot.config.BotConfig
35 35
36 """ 36 """
37 global translations 37 global TRANSLATIONS
38 translations = request_translations(config) or {'en': {}} 38 TRANSLATIONS = request_translations(config) or {'en': {}}
39 39
40 40
41 def request_translations(config): 41 def request_translations(config):
42 """Download translations from wiki using xml rpc 42 """Download translations from wiki using xml rpc
43 43