本文整理汇总了Python中babel.messages.catalog.Catalog.check方法的典型用法代码示例。如果您正苦于以下问题:Python Catalog.check方法的具体用法?Python Catalog.check怎么用?Python Catalog.check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类babel.messages.catalog.Catalog
的用法示例。
在下文中一共展示了Catalog.check方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: po_catalog_export
# 需要导入模块: from babel.messages.catalog import Catalog [as 别名]
# 或者: from babel.messages.catalog.Catalog import check [as 别名]
def po_catalog_export(self):
"""
Export a catalog from a project into a PO file
"""
toast_path = "/home/django/Emencia/po_headquarter/dummy_po/"
project = Project.objects.get(slug='dummy')
catalog = Catalog.objects.get(project=project, locale='fr')
#mime_dict = json.loads(catalog.mime_headers)
forged_catalog = BabelCatalog(
locale=catalog.locale,
header_comment=catalog.header_comment,
project=project.name,
version="0.2.0"
)
print "before add:", len(forged_catalog)
for entry in catalog.translationmsg_set.all().order_by('id'):
locations = [tuple(item) for item in json.loads(entry.template.locations)]
forged_catalog.add(entry.template.message, string=entry.message, locations=locations, flags=entry.template.flags)
print "after add:", len(forged_catalog)
print "errors:", [item for item in forged_catalog.check()]
print
print "---------------- Original"
fpw = StringIO()
write_po(fpw, forged_catalog, sort_by_file=False, ignore_obsolete=True, include_previous=False)
print fpw.getvalue()
fpw.close()
print
print "---------------- Updated"
fp3 = open(os.path.join(toast_path, '0-3-0.pot'), 'r')
template_catalog_3 = read_po(fp3)
forged_catalog.update(template_catalog_3)
fpw = StringIO()
write_po(fpw, forged_catalog, sort_by_file=False, ignore_obsolete=True, include_previous=False)
print fpw.getvalue()
fpw.close()