コード例 #1
0
ファイル: pocompile.py プロジェクト: nijel/translate
 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
ファイル: pocompile.py プロジェクト: AndryulE/kitsune
 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
ファイル: formats.py プロジェクト: sebo77/weblate
 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
ファイル: exporters.py プロジェクト: Yixf-Self/weblate
    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
ファイル: exporters.py プロジェクト: saily/weblate
    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
ファイル: pocompile.py プロジェクト: onia/translate
 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)