Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 3, 2025

Implement feature to report updated vs unchanged PO files in update-po command

  • Explore repository structure and understand the UpdatePoCommand
  • Review existing test scenarios
  • Implement change detection in UpdatePoCommand.php
    • Clone original translations before merging
    • Compare Translation objects to detect actual changes
    • Track updated vs unchanged file counts separately
    • Update success message to show both updated and unchanged files
    • Simplify message formatting logic
  • Add new test scenarios for the change detection feature
    • Test when no files change (POT unchanged)
    • Test when some files change and some don't
  • Update documentation examples in the command docblock
  • Fix change detection to compare objects instead of file content
    • Avoids false positives from timestamp/formatting changes
    • Compares actual translation data, references, and comments
  • Fix method name: use getComments() instead of non-existent getTranslatorComments()

Summary

This PR implements the feature request from issue #333 to improve the update-po command reporting.

Changes Made

  1. UpdatePoCommand.php:

    • Clone original translations before merging
    • Compare Translation objects instead of file content to detect actual changes
    • Added translations_differ() method that compares:
      • Translation counts
      • Individual translation strings and plurals
      • Source code references
      • Extracted comments and translator comments
    • Updated success message to show both updated and unchanged counts
    • Fixed to use correct getComments() method
  2. updatepo.feature:

    • Added test scenario for unchanged files when POT hasn't changed
    • Added test scenario for mixed updated/unchanged files

Output Examples

  • Success: Updated 0 files. 1 file unchanged. - When no files need updating
  • Success: Updated 1 file. - When one file is updated, none unchanged
  • Success: Updated 4 files. 2 files unchanged. - When multiple files, some updated some not

How It Works

The implementation now properly detects changes by comparing Translation objects instead of raw file content. This avoids false positives from timestamp updates or formatting changes that the gettext library makes when writing PO files.

Original prompt

This section details on the original issue you should resolve

<issue_title>update-po: Update/no changes report</issue_title>
<issue_description>## Feature Request

Describe your use case and the problem you are facing
(Side note: The new update-po subcommand is awesome!)

Currently it will report that the PO files were updated, even they hadn't changed (because the POT file hadn't changed).

Describe the solution you'd like
update-po should either report updated files or files that didn't need an update/changing.

Some examples:

Success: Updated 0 files. 1 file unchanged.
Success: Updated 1 file.
Success: Updated 4 files. 2 files unchanged.

This also helps spotting the need for adding/updating translations without using something like a diff tool or inspecting the last modified date of the POT file(s).</issue_description>

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

@swissspidy Thanks for sharing this suggestion 👍

Would need to check if it's easily possible to detect changes/modifications like that.</comment_new>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits November 3, 2025 14:00
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] update-po: Update/no changes report Add update/unchanged file reporting to update-po command Nov 3, 2025
Copilot AI requested a review from swissspidy November 3, 2025 14:06
@codecov
Copy link

codecov bot commented Nov 3, 2025

Codecov Report

❌ Patch coverage is 84.44444% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/UpdatePoCommand.php 84.44% 7 Missing ⚠️

📢 Thoughts on this report? Let us know!

… content

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
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.

update-po: Update/no changes report

2 participants