当前位置: 首页>>代码示例>>Python>>正文


Python Catalog.language方法代码示例

本文整理汇总了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'}}
开发者ID:JMQCode,项目名称:android2po,代码行数:9,代码来源:test_plurals.py

示例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'}}
开发者ID:dasony,项目名称:android2po,代码行数:12,代码来源:test_plurals.py

示例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) == {}
开发者ID:dasony,项目名称:android2po,代码行数:14,代码来源:test_plurals.py

示例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'}}
开发者ID:dasony,项目名称:android2po,代码行数:21,代码来源:test_plurals.py


注:本文中的babel.messages.catalog.Catalog.language方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。