Add placeholder validation to make-mo/make-php/make-json#475
Closed
Add placeholder validation to make-mo/make-php/make-json#475
Conversation
…commands Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add validation for placeholders in make-mo and make-php
Add placeholder validation to make-mo/make-php/make-json
Feb 14, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This comment was marked as resolved.
This comment was marked as resolved.
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request extracts the placeholder validation logic from make-pot into a reusable StringAuditTrait and applies it to make-mo, make-php, and make-json commands. This prevents generation of translation files with incorrect placeholders by issuing warnings during the build process.
Changes:
- Created
StringAuditTraitwith reusable validation logic for checking sprintf placeholders, translator comments, and placeholder consistency - Integrated validation into
make-mo,make-php, andmake-jsoncommands by adding the trait and calling validation before file generation - Updated test scenarios to expect validation warnings and use "I try" instead of "I run" for commands that now output warnings
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/StringAuditTrait.php | New trait containing extracted validation logic for auditing translation strings with placeholders, checking for missing translator comments, empty strings, unordered placeholders, and plural form mismatches |
| src/MakePotCommand.php | Refactored to use StringAuditTrait, delegates audit_strings() to the trait's perform_string_audit() method while keeping regex constants for backward compatibility |
| src/MakeMoCommand.php | Added StringAuditTrait and calls perform_string_audit() before generating MO files |
| src/MakePhpCommand.php | Added StringAuditTrait and calls perform_string_audit() before generating PHP files |
| src/MakeJsonCommand.php | Added StringAuditTrait and calls perform_string_audit() before generating JSON files |
| features/makephp.feature | Updated existing tests to use "I try" and expect warnings, added new test scenario for validation warnings |
| features/makemo.feature | Added new test scenario for validation warnings with placeholders |
| features/makejson.feature | Added new test scenario for validation warnings with placeholders |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Implementation Plan
StringAuditTrait.phptrait to hold reusable validation logicMakePotCommandto use the new traituse StringAuditTraitstatementMakeMoCommandto use the new traituse StringAuditTraitstatementMakePhpCommandto use the new traituse StringAuditTraitstatementMakeJsonCommandto use the new traituse StringAuditTraitstatementOriginal prompt
make-mo/make-php#434💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.