![](/img/trans.png)
[英]Installing weblate 2.3: from django.db.models.sql.aggregates ImportError: No module named aggregates
[英]Basic custom check python module failing to load
我正在嘗試將基本檢查添加為模塊(而不是包),但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
您需要提供類的完全限定路徑,包括 Python 模塊。 有關示例,請參閱https://docs.weblate.org/en/latest/admin/customize.html#custom-check-modules 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.