Skip to content

make-pot: add subtract-and-merge flag - #267

Merged
swissspidy merged 4 commits into
masterfrom
add/subtract-and-merge
Jul 20, 2021
Merged

make-pot: add subtract-and-merge flag#267
swissspidy merged 4 commits into
masterfrom
add/subtract-and-merge

Conversation

@swissspidy

Copy link
Copy Markdown
Member

This PR adds a new --subtract-and-merge flag to the make-pot command, which can be used in combination with --subtract. When used, source code references from the generated POT file will instead be added to the POT file(s) passed to --subtract

Example:

# In foo-plugin/
wp i18n make-pot . foo-plugin.pot --subtract=exceptions.pot

# foo-plugin.pot will not contain any of the strings that are also in exceptions.pot
# exceptions.pot will now however contain all source code references for these strings

While I suggested adding dedicated commands for this feature a few years ago, in hindsight thats seems a bit overkill. It's quite the advanced configuration option that's probably only ever used for WordPress core, so just adding a flag feels like the better choice here.

Fixes #105

@swissspidy

Copy link
Copy Markdown
Member Author

@ocean90 Would this solve the issue for dotorg?

@ocean90

ocean90 commented Jul 13, 2021

Copy link
Copy Markdown
Contributor

@ocean90 Would this solve the issue for dotorg?

As of https://meta.trac.wordpress.org/changeset/10063/ this is actually no issue anymore. My approach is also preserving any comments by using the mergeWith() method. Maybe this should be considered here as well?

@swissspidy

swissspidy commented Jul 13, 2021

Copy link
Copy Markdown
Member Author

Good suggestion with mergeWith() 👍

Are there chances that you would adopt this new --subtract-and-merge flag should it be added? If not, we might not want to bother implementing it.

@ocean90

ocean90 commented Jul 14, 2021

Copy link
Copy Markdown
Contributor

If if works the same as the current implementation, sure why not. Less code I have to maintain. 😅

@schlessera
schlessera force-pushed the add/subtract-and-merge branch from 69d82ce to 008d139 Compare July 19, 2021 16:34
@schlessera schlessera added the command:i18n-make-pot Related to 'i18n make-pot' command label Jul 19, 2021
@swissspidy
swissspidy enabled auto-merge July 20, 2021 10:56
@swissspidy

Copy link
Copy Markdown
Member Author

It should work the same way now and is ready for review.

Comment thread src/MakePotCommand.php Outdated
Co-authored-by: Dominik Schilling <dominikschilling+git@gmail.com>
@swissspidy
swissspidy merged commit 49fb6d9 into master Jul 20, 2021
@delete-merged-branch
delete-merged-branch Bot deleted the add/subtract-and-merge branch July 20, 2021 21:24
@schlessera schlessera added this to the 2.2.9 milestone Jul 20, 2021
schlessera pushed a commit that referenced this pull request Jan 6, 2022
make-pot: add `subtract-and-merge` flag
bazza pushed a commit to WordPress/wordpress.org that referenced this pull request May 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:i18n-make-pot Related to 'i18n make-pot' command

3 participants