Skip to content

fix(i18n): add and correct translators comment placement - #3195

Closed
faisalahammad wants to merge 1 commit into
gocodebox:devfrom
faisalahammad:fix/i18n-missing-translators-comments
Closed

fix(i18n): add and correct translators comment placement#3195
faisalahammad wants to merge 1 commit into
gocodebox:devfrom
faisalahammad:fix/i18n-missing-translators-comments

Conversation

@faisalahammad

Copy link
Copy Markdown
Contributor

Summary

Adds missing // translators: comments above translation calls with placeholders, and corrects structural issues from the bulk i18n commit. All changes are comment-only — no logic or output changes.

Fixes WordPress.WP.I18n.MissingTranslatorsComment PHPCS warnings.

Changes

Standalone <?php // translators: ?> blocks — moved into the same PHP block, directly above the __()/_n()/_x() call. The sniff requires the comment and translation call to be in the same PHP block. Standalone comment-only blocks scattered across HTML were unrecognized.

Orphaned comments above sprintf()/error_log() — moved directly above the __()/_n() call inside the sprintf() args. A comment above sprintf() is not recognized by the sniff even when the gettext call is nested inside.

Capitalized // Translators: — normalized to lowercase // translators: (6 instances across admin tools, bulk-enroll, instructors table). WordPress coding standard uses lowercase.

Duplicate comments — removed where a pre-existing translators comment already existed next to the new one.

Block comment removed — one /* Translators: %s - name of class. */ block comment replaced with standard inline format.

Testing

PHPCS i18n sniff:

# Custom ruleset at /tmp/phpcs-i18n.xml
vendor/bin/phpcs --standard=/tmp/phpcs-i18n.xml includes templates

Result: 0 MissingTranslatorsComment warnings. 2 residual warnings are pre-existing (abstract.llms.update.php false positive, parent-course.php NoHtmlWrappedStrings).

PHP syntax:

git diff HEAD~1 --name-only | xargs -I{} php -l {} 2>&1 | grep -v "No syntax errors"

Result: all files pass.

Full lint:

composer check-cs

Result: exits 0, no new violations.

@faisalahammad
faisalahammad requested a review from brianhogg as a code owner June 18, 2026 19:58
@brianhogg brianhogg moved this to Awaiting Review in Development Jun 18, 2026
Adds missing WordPress.WP.I18n.MissingTranslatorsComment comments above
translation calls containing placeholders, and corrects placement and
casing of comments introduced in the bulk change:

- Moves standalone `<?php // translators: ?>` comment-only blocks into
  the same PHP block, directly above the __()/_n()/_x()/_nx() call.
- Repositions orphaned comments left above sprintf()/error_log() so they
  sit immediately above the translation function call.
- Removes duplicate translators comments where one already existed.
- Normalizes capitalized `// Translators:` to lowercase `// translators:`
  per the WordPress coding standard.

Verification:
- Custom PHPCS ruleset (WordPress.WP.I18n.MissingTranslatorsComment):
  0 warnings (2 residual are pre-existing and out of scope).
- `php -l` clean on all changed files.
- `composer check-cs` exits 0.
@faisalahammad
faisalahammad force-pushed the fix/i18n-missing-translators-comments branch from aafbebb to b3e8f5b Compare June 19, 2026 04:57
@brianhogg

Copy link
Copy Markdown
Contributor

Would rather not flag all these files in a wp.org update. Many of the comments don't really clarify (ie. // translators: %s: value) or are obvious without. Closing for now but can re-open if needed.

@brianhogg brianhogg closed this Jul 20, 2026
@github-project-automation github-project-automation Bot moved this from Awaiting Review to Done in Development Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants