Coverage for app/venv/lib/python3.14/site-packages/weblate/checks/qt.py: 89%
19 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 07:15 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 07:15 +0000
1# Copyright © Michal Čihař <michal@weblate.org>
2#
3# SPDX-License-Identifier: GPL-3.0-or-later
5import re
7from django.utils.translation import gettext_lazy
9from weblate.checks.format import BaseFormatCheck
11QT_FORMAT_MATCH = re.compile(
12 r"""
13 %( # initial %
14 L? # optional localized representation of numbers
15 (?P<ord>\d{1,2}) # variable order, like %1
16 )""",
17 re.VERBOSE,
18)
20QT_PLURAL_MATCH = re.compile(
21 r"""
22 %( # initial %
23 L? # optional localized representation of numbers
24 (?P<type>n) # plural: %n
25 )""",
26 re.VERBOSE,
27)
30class QtFormatCheck(BaseFormatCheck):
31 """Check for Qt format string."""
33 check_id = "qt_format"
34 name = gettext_lazy("Qt format")
35 description = gettext_lazy("Qt format string does not match source.")
36 regexp = QT_FORMAT_MATCH
38 def is_position_based(self, string: str) -> bool:
39 # everything is numbered
40 return False
43class QtPluralCheck(BaseFormatCheck):
44 """Check for Qt plural string."""
46 check_id = "qt_plural_format"
47 name = gettext_lazy("Qt plural format")
48 description = gettext_lazy("Qt plural format string does not match source.")
49 regexp = QT_PLURAL_MATCH
51 def is_position_based(self, string: str) -> bool:
52 return True