本文整理汇总了Python中translate.storage.oo.ooline函数的典型用法代码示例。如果您正苦于以下问题:Python ooline函数的具体用法?Python ooline怎么用?Python ooline使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ooline函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: convertelement
def convertelement(self, theoo):
"""convert an oo element into a list of base units (.po or XLIFF)"""
if self.sourcelanguage in theoo.languages:
part1 = theoo.languages[self.sourcelanguage]
else:
logging.error("/".join(theoo.lines[0].getkey()) +
"language not found: %s", self.sourcelanguage)
return []
if self.blankmsgstr:
# use a blank part2
part2 = oo.ooline()
else:
if self.targetlanguage in theoo.languages:
part2 = theoo.languages[self.targetlanguage]
else:
# if the language doesn't exist, the translation is missing ... so make it blank
part2 = oo.ooline()
if "x-comment" in theoo.languages:
translators_comment = theoo.languages["x-comment"]
else:
translators_comment = oo.ooline()
key = oo.makekey(part1.getkey(), self.long_keys)
unitlist = []
for subkey in ("text", "quickhelptext", "title"):
unit = self.maketargetunit(part1, part2, translators_comment, key, subkey)
if unit is not None:
unitlist.append(unit)
return unitlist
开发者ID:flyeven,项目名称:translate,代码行数:28,代码来源:oo2xliff.py
示例2: applytranslation
def applytranslation(self, key, subkey, theoo, unit):
"""applies the translation from the source unit to the oo unit"""
if not self.includefuzzy and unit.isfuzzy():
return
makecopy = False
if self.languages is None:
part1 = theoo.lines[0]
if len(theoo.lines) > 1:
part2 = theoo.lines[1]
else:
makecopy = True
else:
part1 = theoo.languages[self.languages[0]]
if self.languages[1] in theoo.languages:
part2 = theoo.languages[self.languages[1]]
else:
makecopy = True
if makecopy:
part2 = oo.ooline(part1.getparts())
unquotedid = unit.source
unquotedstr = unit.target
# If there is no translation, we don't want to add a line
if len(unquotedstr) == 0:
return
# finally set the new definition in the oo, but not if its empty
if len(unquotedstr) > 0:
setattr(part2, subkey, unquotedstr)
# set the modified time
if self.timestamp_str:
part2.timestamp = self.timestamp_str
if self.languages:
part2.languageid = self.languages[1]
if makecopy:
theoo.addline(part2)
开发者ID:XLeonardo,项目名称:translate-1,代码行数:34,代码来源:po2oo.py
注:本文中的translate.storage.oo.ooline函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论