ci: compare i18n strings via tokenizer instead of diff lines - #39
Merged
Merged
Conversation
Replace the diff-line scan in tests/bin/check-i18n-pot.php, which had false-positive and false-negative cases, with a tokenizer-based comparison. For the merge-base and for HEAD it tokenizes every template-feeding PHP file (the find . -maxdepth 2 set build_gettext.sh scans), finds the Cacti i18n helper calls, and collects the literal string arguments that actually form each pot entry (msgctxt/msgid/plural per the xgettext -k spec). A call only contributes when those positions are constant strings, mirroring xgettext. If the extracted set differs between base and HEAD, locales/po/cacti.pot must be part of the PR. Reading whole files rather than diff lines means surrounding-code edits and quote-style-only changes no longer trigger it, and multi-line calls are handled correctly. Same fix validated in plugin_reportit #150.
Contributor
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request. Check if the Files changed in this pull request are included in default exclusions.
cigamit
approved these changes
Oct 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Replaces the diff-line scan in
tests/bin/check-i18n-pot.phpwith a tokenizer-based comparison.Why
The current script (shared across the plugin fleet) scans the unified diff line by line and compares whole normalised lines containing an i18n call. That is both too loose and too strict:
__()) demands acacti.potupdate even though the translatable string is unchanged.How
For the merge-base and for HEAD, tokenize every template-feeding PHP file (the same
find . -maxdepth 2 -name '*.php'setbuild_gettext.shscans), find the Cacti i18n helper calls, and collect the literal string arguments that actually form each pot entry — msgctxt/msgid/plural per the xgettext-kspec (__ __n:1,2 __x:1c,2 __xn:1c,2,3 __esc …). A call only contributes when those positions are constant strings, mirroring what xgettext can extract. If the extracted set differs between base and HEAD,locales/po/cacti.potmust be part of the PR.Because it reads whole files via the tokenizer rather than diff lines, surrounding-code edits and quote-style-only changes no longer trigger it, multi-line calls are handled correctly, and method calls/declarations (
$o->__(),C::__(),function __) are excluded.Validation
Same fix as plugin_reportit#150, where it was validated against an 8-case scenario matrix (both bug classes plus the original intended behaviors) with
php -lclean. This PR is the fleet-wide propagation of that fix; the script is byte-identical across repos.