本文整理汇总了Python中translate.storage.tmx.translate函数的典型用法代码示例。如果您正苦于以下问题:Python translate函数的具体用法?Python translate怎么用?Python translate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了translate函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_basic
def test_basic(self):
minipo = r"""# Afrikaans translation of program ABC
#
msgid ""
msgstr ""
"Project-Id-Version: program 2.1-branch\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2006-01-09 07:15+0100\n"
"PO-Revision-Date: 2004-03-30 17:02+0200\n"
"Last-Translator: Zuza Software Foundation <[email protected]>\n"
"Language-Team: Afrikaans <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
# Please remember to do something
#: ../dir/file.xml.in.h:1 ../dir/file2.xml.in.h:4
msgid "Applications"
msgstr "Toepassings"
"""
tmx = self.po2tmx(minipo)
print("The generated xml:")
print(bytes(tmx))
assert tmx.translate("Applications") == "Toepassings"
assert tmx.translate("bla") is None
xmltext = bytes(tmx).decode('utf-8')
assert xmltext.index('creationtool="Translate Toolkit"')
assert xmltext.index('adminlang')
assert xmltext.index('creationtoolversion')
assert xmltext.index('datatype')
assert xmltext.index('o-tmf')
assert xmltext.index('segtype')
assert xmltext.index('srclang')
开发者ID:diorcety,项目名称:translate,代码行数:33,代码来源:test_po2tmx.py
示例2: test_escapedquotes
def test_escapedquotes(self):
"""Test the escaping of quotes (and slash)"""
minipo = r'''msgid "Hello \"Everyone\""
msgstr "Good day \"All\""
msgid "Use \\\"."
msgstr "Gebruik \\\"."
'''
tmx = self.po2tmx(minipo)
print("The generated xml:")
print(bytes(tmx))
assert tmx.translate('Hello "Everyone"') == 'Good day "All"'
assert tmx.translate(r'Use \".') == r'Gebruik \".'
开发者ID:diorcety,项目名称:translate,代码行数:13,代码来源:test_po2tmx.py
示例3: test_nonascii
def test_nonascii(self):
"""Tests that non-ascii conversion works."""
minipo = u'''msgid "Bézier curve"
msgstr "Bézier-kurwe"
'''
tmx = self.po2tmx(minipo)
print(bytes(tmx))
assert tmx.translate(u"Bézier curve") == u"Bézier-kurwe"
开发者ID:diorcety,项目名称:translate,代码行数:8,代码来源:test_po2tmx.py
示例4: test_escapedtabs
def test_escapedtabs(self):
"""Test the escaping of tabs"""
minipo = r'''msgid "First column\tSecond column"
msgstr "Eerste kolom\tTweede kolom"
'''
tmx = self.po2tmx(minipo)
print("The generated xml:")
print(bytes(tmx))
assert tmx.translate("First column\tSecond column") == "Eerste kolom\tTweede kolom"
开发者ID:diorcety,项目名称:translate,代码行数:9,代码来源:test_po2tmx.py
示例5: test_escapednewlines
def test_escapednewlines(self):
"""Test the escaping of newlines"""
minipo = r'''msgid "First line\nSecond line"
msgstr "Eerste lyn\nTweede lyn"
'''
tmx = self.po2tmx(minipo)
print("The generated xml:")
print(bytes(tmx))
assert tmx.translate("First line\nSecond line") == "Eerste lyn\nTweede lyn"
开发者ID:diorcety,项目名称:translate,代码行数:9,代码来源:test_po2tmx.py
示例6: test_multiline
def test_multiline(self):
"""Test multiline po entry"""
minipo = r'''msgid "First part "
"and extra"
msgstr "Eerste deel "
"en ekstra"'''
tmx = self.po2tmx(minipo)
print("The generated xml:")
print(bytes(tmx))
assert tmx.translate('First part and extra') == 'Eerste deel en ekstra'
开发者ID:diorcety,项目名称:translate,代码行数:10,代码来源:test_po2tmx.py
注:本文中的translate.storage.tmx.translate函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论