【发布时间】:2020-12-22 18:19:08
【问题描述】:
我正在尝试将基本检查添加为模块(不是包),但 weblate_celery 无法加载。该文件名为ApostropheCheck.py,与settings.py 主文件保存在同一目录中。
我将它包含在:import ApostropheCheck
并将其添加到活动检查列表中:
CHECK_LIST += (
"ApostropheCheck.ApostropheCheck",
)
检查代码为:
"""Check for consistent apostrophe usage."""
from django.utils.translation import gettext_lazy as _
from weblate.checks.base import TargetCheck
class ApostropheCheck(TargetCheck):
# Used as identifier for check, should be unique
# Has to be shorter than 50 characters
check_id = "apos"
# Short name used to display failing check
name = _("Apostrophe check")
# Description for failing check
description = _("Apostophe counts not consistent with source")
# Real check code
def check_single(self, source, target, unit):
if source.count('`') != target.count('`'): return True
if source.count('"') != target.count('"'): return True
if source.count("'") != target.count("'"): return True
return False
【问题讨论】:
标签: weblate