当前位置: 首页>>代码示例>>Python>>正文


Python po.pounit函数代码示例

本文整理汇总了Python中translate.storage.po.pounit函数的典型用法代码示例。如果您正苦于以下问题:Python pounit函数的具体用法?Python pounit怎么用?Python pounit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pounit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: convertmixedunit

 def convertmixedunit(self, labeldtd, accesskeydtd):
     labelpo = self.convertunit(labeldtd)
     accesskeypo = self.convertunit(accesskeydtd)
     if labelpo is None:
         return accesskeypo
     if accesskeypo is None:
         return labelpo
     thepo = po.pounit(encoding="UTF-8")
     thepo.addlocations(labelpo.getlocations())
     thepo.addlocations(accesskeypo.getlocations())
     thepo.msgidcomment = thepo._extract_msgidcomments() + labelpo._extract_msgidcomments()
     thepo.msgidcomment = thepo._extract_msgidcomments() + accesskeypo._extract_msgidcomments()
     thepo.addnote(labelpo.getnotes("developer"), "developer")
     thepo.addnote(accesskeypo.getnotes("developer"), "developer")
     thepo.addnote(labelpo.getnotes("translator"), "translator")
     thepo.addnote(accesskeypo.getnotes("translator"), "translator")
     # redo the strings from original dtd...
     label = dtd.unquotefromdtd(labeldtd.definition).decode('UTF-8')
     accesskey = dtd.unquotefromdtd(accesskeydtd.definition).decode('UTF-8')
     label = accesskeyfn.combine(label, accesskey)
     if label is None:
         return None
     thepo.source = label
     thepo.target = ""
     return thepo
开发者ID:AlexArgus,项目名称:affiliates-lib,代码行数:25,代码来源:dtd2po.py

示例2: converttransunit

    def converttransunit(self, transunit):
        """makes a pounit from the given transunit"""
        thepo = po.pounit()

        # Header
        if transunit.getrestype() == "x-gettext-domain-header":
            thepo.source = ""
        else:
            thepo.source = transunit.source
        thepo.target = transunit.target

        # Location comments
        locations = transunit.getlocations()
        if locations:
            thepo.addlocations(locations)

        # NOTE: Supporting both <context> and <note> tags in xliff files
        # for comments
        # Translator comments
        trancomments = transunit.getnotes("translator")
        if trancomments:
            thepo.addnote(trancomments, origin="translator")

        # Automatic and Developer comments
        autocomments = transunit.getnotes("developer")
        if autocomments:
            thepo.addnote(autocomments, origin="developer")

        # See 5.6.1 of the spec. We should not check fuzzyness, but approved
        # attribute
        if transunit.isfuzzy():
            thepo.markfuzzy(True)

        return thepo
开发者ID:Jobava,项目名称:translate-toolkit,代码行数:34,代码来源:xliff2po.py

示例3: convertunit

 def convertunit(self, source_str, target_str):
     pounit = po.pounit(encoding="UTF-8")
     pounit.settypecomment('python-format')
     pounit.source = source_str
     if target_str:
         pounit.target = target_str
     return pounit
开发者ID:translate,项目名称:translate,代码行数:7,代码来源:web2py2po.py

示例4: convert_l20nunit

    def convert_l20nunit(self, unit):
        po_unit = po.pounit(encoding="UTF-8")
        po_unit.setid(unit.getid())
        po_unit.addlocation(unit.getid())
        po_unit.source = unit.value
        po_unit.addnote(unit.comment, "developer")

        return po_unit
开发者ID:diorcety,项目名称:translate,代码行数:8,代码来源:l20n2po.py

示例5: convertunit

 def convertunit(self, csvunit):
     """converts csv unit to po unit"""
     pounit = po.pounit(encoding="UTF-8")
     if csvunit.location:
         pounit.addlocation(csvunit.location)
     pounit.source = csvunit.source
     pounit.target = csvunit.target
     return pounit
开发者ID:cc-archive,项目名称:pootle,代码行数:8,代码来源:csv2po.py

示例6: convertunit

 def convertunit(self, inputunit, origin):
     """Converts a .php unit to a .po unit"""
     outputunit = po.pounit(encoding="UTF-8")
     outputunit.addnote(inputunit.getnotes(origin), origin)
     outputunit.addlocation("".join(inputunit.getlocations()))
     outputunit.source = inputunit.source
     outputunit.target = ""
     return outputunit
开发者ID:denji,项目名称:translate,代码行数:8,代码来源:php2po.py

示例7: convertmixedunit

 def convertmixedunit(self, labeldtd, accesskeydtd):
     label_unit = self.convertunit(labeldtd)
     accesskey_unit = self.convertunit(accesskeydtd)
     if label_unit is None:
         return accesskey_unit
     if accesskey_unit is None:
         return label_unit
     target_unit = po.pounit(encoding="UTF-8")
     return self.mixer.mix_units(label_unit, accesskey_unit, target_unit)
开发者ID:alghaamdi,项目名称:translate,代码行数:9,代码来源:dtd2po.py

示例8: convertmixedunit

 def convertmixedunit(self, labelprop, accesskeyprop, commenttype):
     label_unit = self.convertunit(labelprop, commenttype)
     accesskey_unit = self.convertunit(accesskeyprop, commenttype)
     if label_unit is None:
         return accesskey_unit
     if accesskey_unit is None:
         return label_unit
     target_unit = po.pounit(encoding="UTF-8")
     return self.mixer.mix_units(label_unit, accesskey_unit, target_unit)
开发者ID:Alexinger,项目名称:translate,代码行数:9,代码来源:prop2po.py

示例9: count

 def count(self, source, expectedsource, target=None, expectedtarget=None):
     """simple helper to check the respective word counts"""
     poelement = po.pounit(source)
     if target is not None:
         poelement.target = target
     wordssource, wordstarget = statsdb.wordsinunit(poelement)
     print('Source (expected=%d; actual=%d): "%s"' % (expectedsource, wordssource, source))
     assert wordssource == expectedsource
     if target is not None:
         print('Target (expected=%d; actual=%d): "%s"' % (expectedtarget, wordstarget, target))
         assert wordstarget == expectedtarget
开发者ID:flyeven,项目名称:translate,代码行数:11,代码来源:test_pocount.py

示例10: convert_unit

 def convert_unit(self, input_unit, commenttype):
     """Converts a .rc unit to a .po unit. Returns None if empty
     or not for translation."""
     if input_unit is None:
         return None
     # escape unicode
     output_unit = po.pounit(encoding="UTF-8")
     output_unit.addlocation("".join(input_unit.getlocations()))
     output_unit.source = input_unit.source
     output_unit.target = ""
     return output_unit
开发者ID:Jobava,项目名称:translate-toolkit,代码行数:11,代码来源:rc2po.py

示例11: create_pounit

def create_pounit(filename, lineno, message, comments):
    unit = po.pounit(encoding='UTF-8')
    context, msgid = split_context(message)
    unit.setsource(msgid)
    if context:
        unit.msgctxt = ['"%s"' % context]
    for comment in comments:
        unit.addnote(comment, 'developer')

    unit.addlocation('%s:%s' % (filename, lineno))
    return unit
开发者ID:prabushi,项目名称:fjord,代码行数:11,代码来源:extract.py

示例12: test_escaping_newline_tabs

 def test_escaping_newline_tabs(self):
     """test that we handle all kinds of newline permutations"""
     dtdsource = '<!ENTITY  noupdatesfound.intro "A hard coded newline.\\nAnd tab\\t and a \\r carriage return.">\n'
     converter = dtd2po.dtd2po()
     thedtd = dtd.dtdunit()
     thedtd.parse(dtdsource)
     thepo = po.pounit()
     converter.convertstrings(thedtd, thepo)
     print(thedtd)
     print(thepo.source)
     # \n in a dtd should also appear as \n in the PO file
     assert thepo.source == r"A hard coded newline.\nAnd tab\t and a \r carriage return."
开发者ID:anderson916,项目名称:translate,代码行数:12,代码来源:test_dtd2po.py

示例13: convert_unit

    def convert_unit(self, input_unit, commenttype):
        """Converts a JSON unit to a PO unit

        :return: None if empty or not for translation
        """
        if input_unit is None:
            return None
        # escape unicode
        output_unit = po.pounit(encoding="UTF-8")
        output_unit.addlocation(input_unit.getid())
        output_unit.source = input_unit.source
        output_unit.target = ""
        return output_unit
开发者ID:asyschikov,项目名称:translate,代码行数:13,代码来源:json2po.py

示例14: convertfile

 def convertfile(self, tbxfile):
     """Converts a tbxfile to a tbxfile, and returns it. uses templatepo if
     given at construction
     """
     self.pofile = po.pofile()
     for tbxunit in tbxfile.units:
         term = po.pounit()
         term.source = tbxunit.source
         term.target = tbxunit.target
         term.setcontext(tbxunit.getnotes('definition'))
         term.addnote("Part of speech: %s" % tbxunit.getnotes('pos'), 'developer')
         self.pofile.addunit(term)
     self.pofile.removeduplicates()
     return self.pofile
开发者ID:Veterini,项目名称:translate,代码行数:14,代码来源:tbx2po.py

示例15: convert_unit

    def convert_unit(self, input_unit, commenttype):
        """Converts a RESX unit to a PO unit
        @return: None if empty or not for translation
        """
        if input_unit is None:
            return None

        output_unit = po.pounit(encoding="UTF-8")
        output_unit.addlocation(input_unit.getid())
        output_unit.source = input_unit.source
        output_unit.addnote(input_unit.getnotes("developer"), "developer")
        output_unit.target = ""

        return output_unit
开发者ID:PhoneixS,项目名称:translate,代码行数:14,代码来源:resx2po.py


注:本文中的translate.storage.po.pounit函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。