Skip to content

Update PO generator: fix .po files refresh#3570

Merged
arkid15r merged 1 commit into
vacanza:devfrom
KJhellico:upd-po-generator
May 9, 2026
Merged

Update PO generator: fix .po files refresh#3570
arkid15r merged 1 commit into
vacanza:devfrom
KJhellico:upd-po-generator

Conversation

@KJhellico

Copy link
Copy Markdown
Collaborator

Proposed change

The standard compare .po files does not consider comments, so generator didn't consider "changes l10n comments only" and didn't update the file.

#3531 (comment)

Type of change

  • New country/market holidays support (thank you!)
  • Supported country/market holidays update (calendar discrepancy fix, localization)
  • Existing code/documentation/test/process quality improvement (best practice, cleanup, refactoring, optimization)
  • Dependency update (version deprecation/pin/upgrade)
  • Bugfix (non-breaking change which fixes an issue)
  • Breaking change (a code change causing existing functionality to break)
  • New feature (new holidays functionality in general)

Checklist

@coderabbitai

coderabbitai Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Summary by CodeRabbit

  • Refactor
    • Improved translation file change detection to more accurately identify meaningful modifications, including comments and metadata, ensuring translation files are only updated when necessary.

Walkthrough

The PR refines PO file change detection in the localization generation script. A new _is_po_equal helper compares POFile objects by treating message entries and their associated comments (comment and tcomment) as significant equality components. The _update_po_file method now uses this stricter comparison instead of direct file inequality, preventing unnecessary saves when only comments or formatting differ.

Changes

PO File Equality Comparison

Layer / File(s) Summary
Comparison Helper
scripts/l10n/generate_po_files.py
New static method _is_po_equal compares POFile length and per-entry equality, explicitly checking that comment and tcomment fields match.
Change Detection Logic
scripts/l10n/generate_po_files.py
Replaces direct po_file != po_file_initial comparison with _is_po_equal, making change detection aware of comment differences and tightening the gate for when files are saved.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • vacanza/holidays#3279: Adds tests asserting mandatory metadata fields exist, complementing this PR's stricter change detection.
  • vacanza/holidays#3160: Also modifies the PO update logic; synchronizes PO-Revision-Date alongside change detection.
  • vacanza/holidays#2452: Modifies comment reformatting in BY.po; interacts with this PR's comment-aware equality logic.

Suggested labels

script, l10n

Suggested reviewers

  • arkid15r
  • PPsyrius
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the main change: fixing the PO file refresh logic to properly detect and update files when comments change.
Description check ✅ Passed The description clearly explains the bug (standard .po comparison ignores comments), the impact (comment-only changes weren't detected), and the fix, with a direct link to the related discussion.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud

sonarqubecloud Bot commented May 8, 2026

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/l10n/generate_po_files.py`:
- Line 102: The loop pairing entries uses zip(pofile1, pofile2) which should
enforce equal-length iteration; update the loop to call zip with strict=True
(i.e., zip(pofile1, pofile2, strict=True)) to satisfy Ruff B905 and make the
contract explicit—modify the for loop where pofile1 and pofile2 are iterated
together in scripts/l10n/generate_po_files.py (the line containing "for entry1,
entry2 in zip(pofile1, pofile2):").
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1347139c-93da-476a-943d-9846aad3a236

📥 Commits

Reviewing files that changed from the base of the PR and between ff0f538 and 4501d93.

📒 Files selected for processing (1)
  • scripts/l10n/generate_po_files.py

Comment thread scripts/l10n/generate_po_files.py
@codecov

codecov Bot commented May 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (ff0f538) to head (4501d93).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev     #3570   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          314       314           
  Lines        18766     18766           
  Branches      2401      2401           
=========================================
  Hits         18766     18766           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Tip: cubic could auto-approve low-risk PRs like this, if it thinks it's safe to merge. Learn more

@PPsyrius PPsyrius left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM 🌐

@arkid15r arkid15r added this pull request to the merge queue May 9, 2026
Merged via the queue into vacanza:dev with commit ce8963e May 9, 2026
33 checks passed
@KJhellico KJhellico deleted the upd-po-generator branch May 9, 2026 21:35
@KJhellico KJhellico mentioned this pull request May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants