Skip to content

Translation linter work - Rework of #3597#3683

Open
JaminShanti wants to merge 11 commits into
jamulussoftware:mainfrom
JaminShanti:translation-linter-work
Open

Translation linter work - Rework of #3597#3683
JaminShanti wants to merge 11 commits into
jamulussoftware:mainfrom
JaminShanti:translation-linter-work

Conversation

@JaminShanti
Copy link
Copy Markdown

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
Copy link
Copy Markdown
Member

ann0see commented May 10, 2026

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
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.

Copy link
Copy Markdown
Member

@ann0see ann0see left a comment

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
Copy link
Copy Markdown
Member

ann0see commented May 25, 2026

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
Copy link
Copy Markdown
Member

ann0see commented May 25, 2026

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

@ann0see
Copy link
Copy Markdown
Member

ann0see commented May 25, 2026

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
Copy link
Copy Markdown
Member

ann0see commented May 26, 2026

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
Copy link
Copy Markdown
Member

ann0see commented May 26, 2026

That's why it has severity levels. And we should absolutely fail if a translator does obvious mistakes and fix them.

@ignotus666
Copy link
Copy Markdown
Member

Fair enough, but from what I see it flags empty translations as "severe" and all the rest as "warning". If a segment is empty, won't it trigger the rest of the warnings as well? There are empty translations all over the place, because of incomplete translations and also because some segments don't need translating. An empty translation unit should never block the build.

What I'm getting at is that it might be better practice to go to Weblate to look at flagged issues when there's a PR, instead of trawling through translations here and adding another layer of checks that are already performed there.

@ann0see
Copy link
Copy Markdown
Member

ann0see commented May 26, 2026

Empty translation without unfinished must be severe. Empty translation with unfinished is ok as it falls back to the source.

@pljones
Copy link
Copy Markdown
Collaborator

pljones commented May 26, 2026

Anything that shouldn't need translation shouldn't be in the translations, really. We should break on build if they creep in - but, yes, there are a lot to fix.

@ignotus666
Copy link
Copy Markdown
Member

I was rather referring to things like, say, "Ok", or commands. The advice in the docs is that if the translation is the same as the source, to copy the source into the translation. But translators will often ignore that and leave it empty.

@pljones
Copy link
Copy Markdown
Collaborator

pljones commented May 26, 2026

So they need fixing one way or another to be compliant and avoid check errors. No point checking if no one is expected to fix things. Having the build fail does at least make them need fixing.

@JaminShanti
Copy link
Copy Markdown
Author

Let me know if you want any changes.

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

Labels

None yet

Projects

Status: Waiting on Team

Development

Successfully merging this pull request may close these issues.

4 participants