Skip to content

Make PO files the source of truth: remove purge flags from make-json#472

Merged
swissspidy merged 8 commits intomainfrom
copilot/remove-purge-update-flags
Feb 11, 2026
Merged

Make PO files the source of truth: remove purge flags from make-json#472
swissspidy merged 8 commits intomainfrom
copilot/remove-purge-update-flags

Conversation

Copy link
Contributor

Copilot AI commented Feb 9, 2026

The make-json command was destructive by default, removing JS strings from PO files via --purge. This destroyed translations and broke subsequent workflow runs.

Changes

Removed destructive flags from make-json:

  • Eliminated --purge and --update-mo-files flags
  • PO files now remain unmodified
  • Removed remove_js_strings_from_po_file() method

Moved JS-filtering to output commands:

  • Created JsStringFilterTrait with shared filtering logic
  • make-mo and make-php now exclude JS-only strings automatically
  • Keeps MO/PHP files small without touching source PO files

Enhanced JS file detection:

  • Now recognizes .jsx, .ts, .tsx, .mjs, .cjs in addition to .js
  • Uses pathinfo() for proper extension detection

Architecture

Before: make-json modified PO → generated JSON (destructive)

After:

  • make-json reads PO → generates JSON (non-destructive)
  • make-mo/make-php read PO → filter JS-only strings → generate optimized output

PO files are now the single source of truth for deterministic MO, PHP, and JSON generation.

Example

// A translation with mixed references
#: script.js:10
#: admin.php:20
msgid "Save Changes"
msgstr "Änderungen speichern"
  • Before: After make-json, this string would be removed from the PO file if all references were JS
  • After: PO file remains intact; string excluded from MO/PHP files only if all references are JS

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.wordpress.org
    • Triggering command: /usr/bin/curl curl -s REDACTED (dns block)
    • Triggering command: /usr/bin/curl curl -s REDACTED sh or/b�� exec 'git' 'rev---use-map=[{"src/index.js": "build/index.js"},"build/map.json"] (dns block)
    • Triggering command: /usr/bin/curl curl -s REDACTED which or/w�� (dns block)
  • downloads.wordpress.org
    • Triggering command: /usr/bin/curl curl -sSfL REDACTED stty 18n-�� 08303/foo-theme' sh de/node/bin/sh -flags make-mo (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>make-json is is too destructive</issue_title>
<issue_description>Reading the documentation;

[--purge]
Whether to purge the strings that were extracted from the original source file. Defaults to true, use --no-purge to skip the removal.
[--update-mo-files]
Whether MO files should be updated as well after updating PO files. Only has an effect when used in combination with --purge.

Considering my observations, --purge is the default.

But WHY is this a thing in the first place.

I understand why Javascript strings would be removed from the MO file, as the MO is used in PHP only, however, removing the strings from the PO file removes the translations, and thus next run, from the JSON as well.

THIS IS BROKEN.

--no-purge should be the default
--purge should only remove from MO, never from PO.
</issue_description>

<agent_instructions>- Remove the purge and update-mo-files flags from the make-json command

  • The logic from remove_js_strings_from_po_file should be added to MakePhpCommand and MakeMoCommand</agent_instructions>

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

@swissspidy Hi there,

Thanks for opening this issue. Sorry to hear you had an unpleasant experience while working with the wp i18n family of commands.

Considering my observations, --purge is the default.

That is correct. As the documentation says:

Defaults to true, use --no-purge to skip the removal.


This topic has come up before:

Now that the JS translation approach is fairly established in WP and we also have l10n.php translation files (which are preferred over MO files), it probably makes sense to revisit this, perhaps in a more holistic way:

  • .po should always be the source of truth and allow for deterministic generation of mo, php, and json translation files
  • make-mo and make-php should never include JS-only strings to keep them small.
  • this removes the need for the --purge and --update-mo-files flags

This only works of course if leveraging the WP JS translation approach. If you expect your MO files to contain JS-only strings for some reason, then maybe we need to provide an opt-out.</comment_new>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@codecov

This comment was marked as resolved.

Copilot AI and others added 4 commits February 9, 2026 09:46
…ng to make-mo and make-php

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
…g in make-mo/make-php

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

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] Fix make-json to avoid destructive purging Make PO files the source of truth: remove purge flags from make-json Feb 9, 2026
Copilot AI requested a review from swissspidy February 9, 2026 09:55
@swissspidy swissspidy added this to the 2.6.7 milestone Feb 9, 2026
@swissspidy swissspidy marked this pull request as ready for review February 9, 2026 16:49
@swissspidy swissspidy requested a review from a team as a code owner February 9, 2026 16:49
Copilot AI review requested due to automatic review settings February 9, 2026 16:49
@swissspidy

This comment was marked as resolved.

gemini-code-assist[bot]

This comment was marked as resolved.

This comment was marked as resolved.

swissspidy and others added 3 commits February 9, 2026 18:24
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@swissspidy swissspidy merged commit 34bb448 into main Feb 11, 2026
53 checks passed
@swissspidy swissspidy deleted the copilot/remove-purge-update-flags branch February 11, 2026 15:36
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.

make-json is is too destructive

2 participants

Comments