예제 #1
0
def segment_units(store,lang1,lang2):
    from translate.tools import posegment
    from translate.lang import factory
    sourcelang = factory.getlanguage(lang1)
    targetlang = factory.getlanguage(lang2)
    segmenter = posegment.segment(sourcelang, targetlang)
    return segmenter.convertstore(store)
예제 #2
0
 def posegment(self, posource, sourcelanguage, targetlanguage, stripspaces=True, onlyaligned=True):
     """helper that convert po source without requiring files"""
     inputfile = wStringIO.StringIO(posource)
     inputpo = po.pofile(inputfile)
     sourcelang = lang_factory.getlanguage(sourcelanguage)
     targetlang = lang_factory.getlanguage(targetlanguage)
     convertor = posegment.segment(sourcelang, targetlang, stripspaces=stripspaces, onlyaligned=onlyaligned)
     outputpo = convertor.convertstore(inputpo)
     return outputpo
예제 #3
0
 def posegment(self,
               posource,
               sourcelanguage,
               targetlanguage,
               stripspaces=True,
               onlyaligned=True):
     """helper that convert po source without requiring files"""
     inputfile = wStringIO.StringIO(posource)
     inputpo = po.pofile(inputfile)
     sourcelang = lang_factory.getlanguage(sourcelanguage)
     targetlang = lang_factory.getlanguage(targetlanguage)
     convertor = posegment.segment(sourcelang,
                                   targetlang,
                                   stripspaces=stripspaces,
                                   onlyaligned=onlyaligned)
     outputpo = convertor.convertstore(inputpo)
     return outputpo