Пример #1
0
 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)
Пример #2
0
    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
Пример #3
0
    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
Пример #4
0
 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)
Пример #5
0
 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)
Пример #6
0
 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)
Пример #7
0
    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
Пример #8
0
 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)
Пример #9
0
    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
Пример #10
0
 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)