本文整理汇总了Python中babel.messages.catalog.Catalog._num_plurals方法的典型用法代码示例。如果您正苦于以下问题:Python Catalog._num_plurals方法的具体用法?Python Catalog._num_plurals怎么用?Python Catalog._num_plurals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类babel.messages.catalog.Catalog
的用法示例。
在下文中一共展示了Catalog._num_plurals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_write_incorrect_plural
# 需要导入模块: from babel.messages.catalog import Catalog [as 别名]
# 或者: from babel.messages.catalog.Catalog import _num_plurals [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'}}