Back to index

moin  1.9.0~rc2
Functions | Variables
jabberbot.i18n Namespace Reference

Functions

def get_text
def init_i18n
def request_translations

Variables

 TRANSLATIONS = None

Function Documentation

def jabberbot.i18n.get_text (   original,
  lang = "en" 
)
Return a translation of text in the user's language.

    @type original: unicode

Definition at line 14 of file i18n.py.

00014 
00015 def get_text(original, lang="en"):
00016     """ Return a translation of text in the user's language.
00017 
00018         @type original: unicode
00019     """
00020     if original == u"":
00021         return u""
00022 
00023     global TRANSLATIONS
00024     if not TRANSLATIONS:
00025         init_i18n(BotConfig)
00026 
00027     try:
00028         return TRANSLATIONS[lang][original]
00029     except KeyError:
00030         return original
00031 

Here is the call graph for this function:

def jabberbot.i18n.init_i18n (   config)
Prepare i18n

@type config: jabberbot.config.BotConfig

Definition at line 32 of file i18n.py.

00032 
00033 def init_i18n(config):
00034     """Prepare i18n
00035 
00036     @type config: jabberbot.config.BotConfig
00037 
00038     """
00039     global TRANSLATIONS
00040     TRANSLATIONS = request_translations(config) or {'en': {}}
00041 

Here is the call graph for this function:

Here is the caller graph for this function:

Download translations from wiki using xml rpc

@type config: jabberbot.config.BotConfig

Definition at line 42 of file i18n.py.

00042 
00043 def request_translations(config):
00044     """Download translations from wiki using xml rpc
00045 
00046     @type config: jabberbot.config.BotConfig
00047 
00048     """
00049 
00050     wiki = xmlrpclib.Server(config.wiki_url + "?action=xmlrpc2")
00051     log = logging.getLogger(__name__)
00052     log.debug("Initialising i18n...")
00053 
00054     try:
00055         translations =  wiki.getBotTranslations()
00056         return translations
00057     except xmlrpclib.Fault, fault:
00058         log.error("XML RPC fault occured while getting translations: %s" % (str(fault), ))
00059     except xmlrpclib.Error, error:
00060         log.error("XML RPC error occured while getting translations: %s" % (str(error), ))
00061     except Exception, exc:
00062         log.error("Unexpected exception occured while getting translations: %s" % (str(exc), ))
00063 
00064     log.error("Translations could not be downloaded, is wiki is accesible?")
00065     return None

Here is the caller graph for this function:


Variable Documentation

Definition at line 11 of file i18n.py.