-
Notifications
You must be signed in to change notification settings - Fork 58
Add dedicated wp i18n audit command with JSON and GitHub Actions output formats
#459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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>
wp i18n audit command with JSON and GitHub Actions output formats
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
@copilot There's a lot of duplicated code between this new Also note that you hallucinated some methods such as |
…lication Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Refactored AuditCommand to extend MakePotCommand, eliminating ~188 lines of duplicated code (~28% reduction) and fixing the hallucinated methods. The command now properly reuses the parent class's file type detection, main file discovery, and string extraction logic while maintaining full control over audit output formatting. (commit 242d6aa) |
|
@copilot With the audit command, when a format such as JSON is used, there shouldn't be any additional output such as "Plugin file detected." or "Warning: Found 1 issue." Maybe you can achieve this with a quiet logger or so. |
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Implemented clean output for JSON and GitHub Actions formats by overriding |
|
@copilot There's one failing test remaining: |
…f text domain Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
There was a problem hiding this 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 PR introduces a new wp i18n audit command to scan WordPress projects for potential translation issues. The command reuses the string extraction logic from MakePotCommand but provides specialized output formats (plaintext, JSON, GitHub Actions) for auditing purposes.
Key Changes
- Added
AuditCommandclass extendingMakePotCommandto detect common i18n issues like missing translator comments, unordered placeholders, and empty strings - Registered the new
i18n auditcommand with mbstring requirement check - Added comprehensive test coverage through Behat scenarios
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/AuditCommand.php | New command class that extracts and analyzes translatable strings for common issues |
| i18n-command.php | Registers the i18n audit command with mbstring extension check |
| features/audit.feature | Behat test scenarios covering various audit checks and output formats |
| composer.json | Adds the new command to the bundled commands list |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Implementation of
wp i18n auditcommand - Complete ✅Latest Updates
Fixed
--ignore-domainflag handling:--ignore-domainis used, domain is now properly left unset to extract all strings regardless of text domainwp i18n make-pot --ignore-domainSuppressed informational messages in non-plaintext formats:
--format=jsonor--format=github-actions, the command now only outputs the formatted dataMajor Refactoring (addressing code review feedback)
Refactored AuditCommand to extend MakePotCommand instead of duplicating code:
FileDataExtractor::get_file_type(),FileDataExtractor::find_main_file())Key Changes
Refactored AuditCommand class (
src/AuditCommand.php):MakePotCommandto reuse string extraction logicget_main_file_data()to conditionally suppress log messages based on format--ignore-domainflag to extract all stringsfile:line: messageformat with informational messages (addressing File name BEFORE the Warning & full path #119)get_comment_text()to reduce code duplicationCommand registration (
i18n-command.php): UnchangedTest coverage (
features/audit.feature): All tests now passingAudit Checks Implemented
Backward Compatibility
✅ The existing audit functionality in
wp i18n make-potremains completely unchanged.Code Quality Improvements
--ignore-domainflag handlingOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.