Skip to content

Translation linter work - Rework of #3597 - #3683

Merged
ann0see merged 17 commits into
jamulussoftware:mainfrom
JaminShanti:translation-linter-work
Sep 14, 2026
Merged

ann0see merged 17 commits into
jamulussoftware:mainfrom
JaminShanti:translation-linter-work

Conversation

@JaminShanti

Copy link
Copy Markdown
Contributor

Short description of changes
Rework of #3597

Introduces an extended Python-based Qt .ts translation checker. This tool validates translation files according to Qt Linguist semantics, catching common formatting and syntax issues such as:

  • Empty translations
  • Placeholder mismatches (%1, %2, etc.)
  • Missing HTML tags
  • Leading/trailing whitespace inconsistencies
  • Newline mismatches

It features a strict mode (--strict) designed for CI pipeline integration, which exits with a non-zero code when warnings or severe errors are present. It also outputs a detailed test summary organized by language.

CHANGELOG: SKIP

Context: Fixes an issue?

Context: This provides a more robust, automated way to ensure the quality and consistency of internationalization (i18n) files, reducing the manual review overhead required for ongoing translation updates.

Does this change need documentation? What needs to be documented and how?

No end-user documentation is required on the website. A brief note should likely be added to CONTRIBUTING.md or the developer documentation explaining how contributors or CI runners can execute the script against the src/translation directory.

Status of this Pull Request

Working implementation.

What is missing until this pull request can be merged?

  • Review from the core team on the specific validation rules to ensure the severity levels align with the project's standards.
  • Integration into the automated GitHub Actions / CI workflow.

Checklist

  • I've verified that this Pull Request follows the general code principles
  • I tested my code and it does what I want
  • My code follows the style guide
  • I waited some time after this Pull Request was opened and all GitHub checks completed without errors.
  • I've filled all the content above

ann0see and others added 3 commits February 8, 2026 15:03
Make script executable

Add PR commenting logic

Add pygithub dependency

Fix import

Remove GitHub requirements

Refactor test suite

Fix some errors

Add styling

Add severity

Be closer to qtlinguist semantics
Comment thread tools/check-translations.py
@ann0see

ann0see commented May 10, 2026

Copy link
Copy Markdown
Member

Please rebase this too such that we have no conflicts

@ann0see ann0see added this to Tracking May 10, 2026
@github-project-automation github-project-automation Bot moved this to Triage in Tracking May 10, 2026
@ann0see ann0see added this to the Release 4.0.0 milestone May 10, 2026
@ann0see ann0see moved this from Triage to Waiting on Team in Tracking May 18, 2026
Comment thread .github/workflows/translation-check.yml Outdated
Comment thread tools/check-translations.py Outdated
@ann0see
ann0see self-requested a review May 25, 2026 20:19
Comment thread tools/check-translations.py Outdated
Comment on lines +80 to +91
def approximate_message_lines(text: str):
"""Yield approximate line numbers for <message> elements."""
lines = text.splitlines()
cursor = 0
for _ in range(text.count("<message")):
for i in range(cursor, len(lines)):
if "<message" in lines[i]:
cursor = i + 1
yield i + 1
break
else:
yield 0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a TODO to think about how to not need to approximate the line numbers. I know it's from the original version and ChatGPT came up with it as hack.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tired something different. See if you think it's an improvement or I can revert.

@ann0see ann0see left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll need to check it myself locally again, but we should be ready soon.

@ann0see

ann0see commented May 25, 2026

Copy link
Copy Markdown
Member

A brief note should likely be added to CONTRIBUTING.md

Maybe. Not sure. Since it'll fail if there's an issue, the translation CI will complain.

@ann0see
ann0see requested a review from ignotus666 May 25, 2026 20:24
@ann0see

ann0see commented May 25, 2026

Copy link
Copy Markdown
Member

@ignotus666 maybe you could also have a look at the general concept of this script. It should find some issues (definitely not everything).

@ann0see

ann0see commented May 25, 2026

Copy link
Copy Markdown
Member

Related: #2902

@JaminShanti
JaminShanti force-pushed the translation-linter-work branch from cc3fb03 to 4027304 Compare May 25, 2026 22:11
@ignotus666

Copy link
Copy Markdown
Member

Weblate already does all of these checks. I personally don't see the need for this - it's going to be constantly causing CI failures.

@ann0see

ann0see commented May 26, 2026

Copy link
Copy Markdown
Member

Really? Most of those are based on what I'd check manually on PRs. So we may need to add other things.

@ignotus666

Copy link
Copy Markdown
Member

Weblate flags all those issues plus a few others (inconsistencies, markdown links, references and syntax, multiple capitals...). It just doesn't block anything on that basis, only providing warnings - it's up to translators to address the flagged issues. If they don't bother on Weblate I don't see how flagging them again here is going to change anything. It's often the case that they are false positives and can be ignored (you can tell Weblate to do that) due to particularities of different languages, or in the case of empty translations because that particular segment doesn't need translating. If the script here causes the CI build to fail I can guarantee you'll never see a successful build again.

@ann0see

ann0see commented Jul 11, 2026

Copy link
Copy Markdown
Member

@JaminShanti could you please have a look at the comments by @softins ?

@JaminShanti

Copy link
Copy Markdown
Contributor Author

Here's a test.ts example, @softins

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="de_DE">
<context>
    <name>TestContext</name>
    
    <message>
        <source>Please click ok.</source>
        <translation></translation> 
    </message>

    <message>
        <source>Loaded %1 files out of %2.</source>
        <translation>Es wurden %1 Dateien geladen.</translation> 
    </message>

    <message>
        <source>Click &lt;b&gt;here&lt;/b&gt; to continue.</source>
        <translation>Klicken Sie hier to continue.</translation>
    </message>

    <message>
        <source> Welcome to Jamulus </source>
        <translation>Willkommen bei Jamulus</translation>
    </message>

    <message>
        <source>First Line\nSecond Line</source>
        <translation>Erste Zeile Zweite Zeile</translation>
    </message>

    <message>
        <source>Old text</source>
        <translation type="obsolete">Alter Text</translation>
    </message>
</context>
</TS>

@pljones pljones added the tooling Changes to the automated build system label Jul 19, 2026
@pljones pljones modified the milestones: Release 4.0.0, Release 4.1.0 Jul 19, 2026
@pljones

pljones commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Moving to 4.1.0 as it's stalled.

@pljones pljones moved this from Waiting on Team to Backlog in Tracking Jul 20, 2026
@ann0see ann0see added the AI AI generated or potentially AI generated label Jul 21, 2026
@ann0see

ann0see commented Jul 21, 2026

Copy link
Copy Markdown
Member

I think this could still go into 4.0.0 ?

@mcfnord

mcfnord commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

MY LLM WROTE:

Ran the checker at this PR's head against the current 16 src/translation/*.ts, exactly as the workflow invokes it:

$ ./tools/check-translations.py --ts-dir src/translation ; echo $?
[ja_JP] Severe: 0, Warnings: 3
[zh_CN] Severe: 0, Warnings: 1
0

Exit 0. Adding --strict to the same run gives exit 1.

Only two paths emit SEVERE: an empty <translation> not marked type="unfinished", and XML parse errors. Placeholder, HTML, whitespace and newline mismatches are all WARNING, and warnings only reach the exit code under --strict, which the workflow doesn't pass. Strings marked unfinished are skipped by every check.

The four review items from May are in the current diff: TTY-aware --color, vanished/obsolete excluded, error message when no .ts files are found, example fixture.

Does this unblock 4.0.0?

Comment thread tools/check-translations.py Outdated
#
##############################################################################
#
# This program is free software; you can redistribute it and/or modify it under

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong licence for new code.

Comment thread tools/check-translations.py Outdated
@JaminShanti

Copy link
Copy Markdown
Contributor Author

@ann0see / @pljones - Checking in on this PR. I know you both have been prioritizing the backlog of other AI-generated PRs, so I don't want to add unnecessary pressure. Just gently bumping this one up for whenever you have a moment to review the linter changes. Happy to address any feedback when you get to it!

@ann0see

ann0see commented Sep 12, 2026

Copy link
Copy Markdown
Member

I'd still like to get this in.

@github-project-automation github-project-automation Bot moved this from Backlog to Waiting on Team in Tracking Sep 14, 2026
@ann0see
ann0see merged commit cc40a8a into jamulussoftware:main Sep 14, 2026
16 checks passed
@github-project-automation github-project-automation Bot moved this from Waiting on Team to Done in Tracking Sep 14, 2026
@ann0see

ann0see commented Sep 14, 2026

Copy link
Copy Markdown
Member

Let's hope this helps us finding issues faster...

@ann0see ann0see modified the milestones: Release 4.1.0, Release 4.0.0 Sep 14, 2026
@ann0see

ann0see commented Sep 14, 2026

Copy link
Copy Markdown
Member

Thank you for picking this up @JaminShanti I believe that you can now add yourself as contributor in the about dialog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI AI generated or potentially AI generated tooling Changes to the automated build system

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants