本文整理汇总了Python中babel.messages.Catalog._num_plurals方法的典型用法代码示例。如果您正苦于以下问题:Python Catalog._num_plurals方法的具体用法?Python Catalog._num_plurals怎么用?Python Catalog._num_plurals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类babel.messages.Catalog
的用法示例。
在下文中一共展示了Catalog._num_plurals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_export
# 需要导入模块: from babel.messages import Catalog [as 别名]
# 或者: from babel.messages.Catalog import _num_plurals [as 别名]
def test_export(self):
"""Test that the export command maintains the proper plural form,
and actually replaces an incorrect one."""
p = self.setup_project()
p.write_xml(data="""<resources></resources>""")
p.write_xml(data="""<resources></resources>""", lang='ja')
# Generate a catalog with different plural rules than we expect
catalog = Catalog('ja')
catalog._num_plurals, catalog._plural_expr = 2, '(n < 2)'
p.write_po(catalog)
# Export should override the info
assert 'Plural-Forms header' in p.program('export')
catalog = p.get_po('ja.po')
assert catalog.num_plurals == 1
assert catalog.plural_expr == '(0)'