Skip to content

Commit 69e9f5c

Browse files
committed
Document dennis linter 📝
1 parent 6fec80c commit 69e9f5c

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

changedetectionio/translations/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,58 @@ Babel auto-discovers the new language on subsequent runs.
223223

224224
---
225225

226+
## Dennis linter
227+
228+
We use [mozilla/dennis](https://github.com/mozilla/dennis) to enforce technical correctness in `.po` and `.pot` files.
229+
See the [Table of Warnings and Errors](https://dennis.readthedocs.io/en/latest/linting.html#table-of-warnings-and-errors)
230+
for the full list of rules.
231+
232+
### Running the linter locally
233+
234+
To match the CI checks, run the following commands:
235+
236+
```bash
237+
# Check for errors only (always enforced)
238+
dennis-cmd lint --errorsonly changedetectionio/translations/
239+
240+
# Check for warnings (excluding W302 unchanged translations)
241+
dennis-cmd lint --excluderules=W302 changedetectionio/translations/
242+
```
243+
244+
### Common issues and fixes
245+
246+
#### HTML tag mismatch (`W303`)
247+
248+
The `W303` rule ensures that HTML tags in the `msgstr` match the `msgid`. This is crucial for catching broken markup (e.g., missing closing tags).
249+
250+
##### Handling intentional deviations and false positives
251+
252+
Some W303 warnings are intentional or result from upstream false positives.
253+
Use the `dennis-ignore: W303` comment in the source files (templates or Python code) within a `TRANSLATORS` comment to suppress these warnings.
254+
This ensures the ignore instruction is extracted into the `.po` files.
255+
256+
- **CJK italic policy**: When replacing `<i>` with locale-conventional quotation marks, tags will no longer match.
257+
- **Upstream false positive**: Dennis misinterprets certain HTML tags (e.g., `<title>`) within `msgstr`. See https://github.com/mozilla/dennis/issues/213.
258+
259+
**Examples in Jinja2 templates:**
260+
261+
```jinja
262+
{# TRANSLATORS: CJK fonts lack native italics; allow substitution with conventional local styling. dennis-ignore: W303 #}
263+
<p>{{ _('These settings are <strong><i>added</i></strong> to any existing watch configurations.')|safe }}</p>
264+
265+
{# TRANSLATORS: dennis-ignore: W303 - False positive caused by <title>. https://github.com/mozilla/dennis/issues/213 #}
266+
<td>{{ _('The page title of the watch, uses <title> if not set, falls back to URL') }}</td>
267+
```
268+
269+
**Example in Python source:**
270+
271+
```python
272+
# dennis-ignore: W303 - False positive caused by <title>. https://github.com/mozilla/dennis/issues/213
273+
use_page_title_in_list = BooleanField(_l('Use page <title> in watch overview list'))
274+
```
275+
276+
---
277+
226278
## CI linter
227279

228280
A GitHub Actions job (`lint-template-i18n`) checks for adjacent `{{ _(...) }}` calls on the same line

0 commit comments

Comments
 (0)