本文整理汇总了Python中babel.messages.catalog.Catalog.language方法的典型用法代码示例。如果您正苦于以下问题:Python Catalog.language方法的具体用法?Python Catalog.language怎么用?Python Catalog.language使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类babel.messages.catalog.Catalog
的用法示例。
在下文中一共展示了Catalog.language方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_write_incomplete_plural
# 需要导入模块: from babel.messages.catalog import Catalog [as 别名]
# 或者: from babel.messages.catalog.Catalog import language [as 别名]
def test_write_incomplete_plural():
"""Test behaviour with incompletely translated plurals in .po."""
catalog = Catalog()
catalog.language = Language('bs') # Bosnian
catalog.add(('foo', 'foos'), ('one', '', 'many', ''), context='foo')
assert po2xml(catalog) == {'foo': {
'few': '', 'many': 'many', 'other': '', 'one': 'one'}}
示例2: test_write
# 需要导入模块: from babel.messages.catalog import Catalog [as 别名]
# 或者: from babel.messages.catalog.Catalog import language [as 别名]
def test_write():
"""Test a basic po2xml() call.
(what the import command does).
"""
catalog = Catalog()
catalog.language = Language('bs') # Bosnian
catalog.add(('foo', 'foos'), ('few', 'many', 'one', 'other'), context='foo')
assert po2xml(catalog) == {'foo': {
'few': 'few', 'many': 'many', 'one': 'one', 'other': 'other'}}
示例3: test_write_ignore_untranslated_plural
# 需要导入模块: from babel.messages.catalog import Catalog [as 别名]
# 或者: from babel.messages.catalog.Catalog import language [as 别名]
def test_write_ignore_untranslated_plural():
"""An untranslated plural is not included in the XML.
"""
catalog = Catalog()
catalog.language = Language('en')
catalog.add(('foo', 'foos'), context='foo')
assert po2xml(catalog) == {}
# Even with ``with_untranslated``, we still do not include
# empty plural (they would just block access to the untranslated
# master version, which we cannot copy into the target).
assert po2xml(catalog) == {}
示例4: test_write_incorrect_plural
# 需要导入模块: from babel.messages.catalog import Catalog [as 别名]
# 或者: from babel.messages.catalog.Catalog import language [as 别名]
def test_write_incorrect_plural():
"""Test what happens when the .po catalog contains the wrong
plural information.
"""
catalog = Catalog()
catalog.language = Language('lt') # Lithuanian
# Lithuanian has three plurals, we define 2.
catalog._num_plurals, catalog._plural_expr = 2, '(n != 1)'
catalog.add(('foo', 'foos'), ('a', 'b',), context='foo')
wfunc = TestWarnFunc()
xml = po2xml(catalog, warnfunc=wfunc)
# A warning was written
assert len(wfunc.logs) == 1
assert '2 plurals, we expect 3' in wfunc.logs[0]
# The missing plural is empty
assert xml == {'foo': {'few': 'a', 'other': None, 'one': 'b'}}