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_storage(self): store = mofile() # Set po file header store.updateheader( add=True, language=self.language.code, x_generator='Weblate {0}'.format(weblate.VERSION), project_id_version='{0} ({1})'.format(self.language.name, self.project.name), plural_forms=self.language.get_plural_form(), language_team='{0} <{1}>'.format(self.language.name, self.url)) return store
def get_storage(self): store = mofile() # Set po file header store.updateheader(add=True, language=self.language.code, x_generator='Weblate %s' % weblate.VERSION, project_id_version='%s (%s)' % (self.language.name, self.project.name), plural_forms=self.language.get_plural_form(), language_team='%s <%s>' % ( self.language.name, self.url, )) return store
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)
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 get_storage(self): store = mofile() # Set po file header store.updateheader( add=True, language=self.language.code, x_generator='Weblate %s' % weblate.VERSION, project_id_version='%s (%s)' % ( self.language.name, self.project.name ), plural_forms=self.language.get_plural_form(), language_team='%s <%s>' % ( self.language.name, self.url, ) ) return store
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)
def get_storage(self): store = mofile() # Set po file header store.updateheader( add=True, language=self.language.code, x_generator='Weblate {0}'.format(weblate.VERSION), project_id_version='{0} ({1})'.format( self.language.name, self.project.name ), plural_forms=self.language.get_plural_form(), language_team='{0} <{1}>'.format( self.language.name, self.url ) ) return store
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) 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 str(outputfile)