def convertstore(inputfile, includefuzzy=False): outputfile = mo.mofile() for unit in inputfile.units: if (unit.istranslated() or (unit.isfuzzy() and includefuzzy and unit.target) or unit.isheader()): mounit = mo.mounit() if unit.isheader(): mounit.source = "" else: mounit.source = unit.source context = unit.getcontext() if unit.msgidcomment: if mounit.hasplural(): mounit.source = multistring( _do_msgidcomment(unit.msgidcomment) + mounit.source, *mounit.source.strings[1:]) else: mounit.source = ( _do_msgidcomment(unit.msgidcomment) + mounit.source) elif context: mounit.msgctxt = [context] mounit.target = unit.target outputfile.addunit(mounit) return bytes(outputfile)
def get_language_pack(self): ''' Generates compiled messages file. ''' outputfile = mo.mofile() for unit in self.store.units: if not unit.istranslated() and not unit.isheader(): continue mounit = mo.mounit() if unit.isheader(): mounit.source = "" else: mounit.source = unit.source mounit.msgctxt = [unit.getcontext()] mounit.target = unit.target outputfile.addunit(mounit) return str(outputfile)
def convertstore(self, inputfile, includefuzzy=False): outputfile = mo.mofile() for unit in inputfile.units: if unit.istranslated() or (unit.isfuzzy() and includefuzzy and unit.target): mounit = mo.mounit() if unit.isheader(): mounit.source = "" else: mounit.source = unit.source if hasattr(unit, "msgidcomments"): mounit.source.strings[0] = po.unquotefrompo( unit.msgidcomments) + mounit.source.strings[0] if hasattr(unit, "msgctxt"): mounit.msgctxt = po.unquotefrompo(unit.msgctxt) mounit.target = unit.target outputfile.addunit(mounit) return str(outputfile)