fix(i18n): add and correct translators comment placement#3195
Open
faisalahammad wants to merge 1 commit into
Open
fix(i18n): add and correct translators comment placement#3195faisalahammad wants to merge 1 commit into
faisalahammad wants to merge 1 commit into
Conversation
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.
aafbebb to
b3e8f5b
Compare
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.
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 thesprintf()args. A comment abovesprintf()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 templatesResult: 0 MissingTranslatorsComment warnings. 2 residual warnings are pre-existing (abstract.llms.update.php false positive, parent-course.php NoHtmlWrappedStrings).
PHP syntax:
Result: all files pass.
Full lint:
Result: exits 0, no new violations.