Skip to content

Add placeholder validation to make-mo/make-php/make-json#475

Closed
Copilot wants to merge 7 commits intomainfrom
copilot/validate-strings-placeholders
Closed

Add placeholder validation to make-mo/make-php/make-json#475
Copilot wants to merge 7 commits intomainfrom
copilot/validate-strings-placeholders

Conversation

Copy link
Contributor

Copilot AI commented Feb 14, 2026

Implementation Plan

  • Create a new StringAuditTrait.php trait to hold reusable validation logic
    • Extract regex constants from MakePotCommand
    • Extract the core audit_strings validation logic
    • Make validation logic flexible (not dependent on project_type/get_file_headers)
  • Update MakePotCommand to use the new trait
    • Add use StringAuditTrait statement
    • Update audit_strings to call trait method
    • Keep regex constants in class for backward compatibility
  • Update MakeMoCommand to use the new trait
    • Add use StringAuditTrait statement
    • Call perform_string_audit after loading translations
  • Update MakePhpCommand to use the new trait
    • Add use StringAuditTrait statement
    • Call perform_string_audit after loading translations
  • Update MakeJsonCommand to use the new trait
    • Add use StringAuditTrait statement
    • Call perform_string_audit after loading translations
  • Add tests for the new validation behavior
    • Test validation warnings in make-mo
    • Test validation warnings in make-php
    • Test validation warnings in make-json
  • Run linting and existing tests to ensure no regressions
  • Security scan with CodeQL
  • Final code review
    • Address code review feedback
    • Fix strpos() warning caused by incorrect namespace
    • Update existing tests to expect validation warnings
    • Fix failing tests by using "try" instead of "run"
Original prompt

This section details on the original issue you should resolve

<issue_title>Validate strings with placeholders in make-mo/make-php</issue_title>
<issue_description>This is a follow-up to #427

Ideally we add some validation logic to make-mo and make-php as well. We already do some validation in make-pot (see audit_strings() method, which we could extract into a reusable trait.

Maybe make-json too?

Prevents you from generating translation files with incorrect placeholders in them.</issue_description>

Comments on the Issue (you are @copilot in this section)


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

Copilot AI and others added 3 commits February 14, 2026 22:38
…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
Copilot AI requested a review from swissspidy February 14, 2026 22:45
@codecov
Copy link

codecov bot commented Feb 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@swissspidy

This comment was marked as resolved.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

@swissspidy

This comment was marked as resolved.

Copilot AI and others added 2 commits February 15, 2026 17:22
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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 StringAuditTrait with reusable validation logic for checking sprintf placeholders, translator comments, and placeholder consistency
  • Integrated validation into make-mo, make-php, and make-json commands 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.

@swissspidy swissspidy closed this Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validate strings with placeholders in make-mo/make-php

2 participants