All pastes #88822 Raw Edit

Donno

public python v1 · immutable
#88822 ·published 2006-07-15 10:35 UTC
rendered paste body
class Language:    """        Language Class            For reading in xml for automatiacall of the selected lanauge XBMC is running in            And for returning the string in the given langue for a specified id        Oringally Coded by Rockstar, Recoded by Donno :D    """    def load(self,path):        self.strings = {}        tempstrings = []        self.language = xbmc.getLanguage().lower()        if os.path.exists(path+self.language+".xml"):            self.foundlang = self.language        else:            self.foundlang = "english"        self.langdoc = path+self.foundlang+".xml"        print "-Loading Language: " + self.foundlang        try:            f=open(self.langdoc,'r')            tempstrings=f.read()            f.close()        except:            print "Error: Languagefile "+self.langdoc+" cant be opened"            xbmcgui.Dialog().ok(__title__,"Error","Languagefile "+self.langdoc+" cant be opened")        self.exp='<string id="(.*?)">(.*?)</string>'        self.res=re.findall(self.exp,tempstrings)        for stringdat in self.res:            self.strings[int(stringdat[0])] = str(stringdat[1])    def string(self,number):        if int(number) in self.strings:            return self.strings[int(number)]        else:            return "unknown string id"