Skip to content

Conversation

@iangmaia
Copy link
Contributor

@iangmaia iangmaia commented Jan 12, 2026

Fixes AINFRA-1724
See discussion on Slack: p1767962906955309-slack-CC7L49W13
See test PR: woocommerce/woocommerce-ios#16502

Summary

The main goal of this PR is to fix the issue when generating the .po / .pot files where new entries aren't present in the output or removed entries are removed. To do that, I've consolidated the metadata PO file generation into a new PoFileGenerator class using gettext. The ios_update_metadata_source and an_update_metadata_source actions are now deprecated and delegate to gp_update_metadata_source.

What's Changed

New Features:

  • Translator comments: source_files now accepts { path: 'file.txt', comment: 'translators: ...' } format
  • commit_changes option: Auto-commit support on gp_update_metadata_source

Output Changes:

  • Entries sorted alphabetically by msgctxt for deterministic output
  • Translator comments (#. lines) must now be explicitly provided—they're no longer preserved from existing PO files
  • PO-Revision-Date is now updated with the current date time

Breaking Changes

  1. Entry order will change in generated PO files
  2. Translator comments will be lost unless migrated to the new format:
# Before
source_files: { app_store_subtitle: 'path/to/subtitle.txt' }

# After (to preserve comments)
source_files: {
  app_store_subtitle: {
    path: 'path/to/subtitle.txt',
    comment: 'translators: Limit to 30 characters!'
  }
}

Migration

When upgrading, callers need to copy comments from .po/.pot files to the gp_update_metadata_source call site in the Fastfile to make sure the comments remain in the generated file. See MIGRATION.md for details.

Deprecations

Old Action Replacement
ios_update_metadata_source gp_update_metadata_source with commit_changes: true
an_update_metadata_source gp_update_metadata_source

Deprecated actions still work (API unchanged) but the output will be different (the comments and header will be removed and the keys will be sorted alphabetically, mainly).

@iangmaia iangmaia self-assigned this Jan 12, 2026
@dangermattic
Copy link
Collaborator

dangermattic commented Jan 12, 2026

1 Warning
⚠️ This PR is larger than 500 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.

Generated by 🚫 Danger

iangmaia and others added 2 commits January 12, 2026 13:40
- Rename `po` parameter to `po_data` (min 3 chars)
- Fix context description wording in spec

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@iangmaia iangmaia force-pushed the iangmaia/refactor-po-generation branch from 9e9b07e to 2dc9458 Compare January 12, 2026 13:44
@iangmaia iangmaia marked this pull request as draft January 12, 2026 15:03
@iangmaia iangmaia force-pushed the iangmaia/refactor-po-generation branch from 2dc9458 to fc65181 Compare January 12, 2026 15:04
@iangmaia iangmaia changed the title Refactor PO generation with PoFileGenerator Refactor metadata PO files generation Jan 12, 2026
@iangmaia iangmaia added bug Something isn't working enhancement New feature or request labels Jan 12, 2026
@iangmaia iangmaia marked this pull request as ready for review January 12, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants