i18n-command icon indicating copy to clipboard operation
i18n-command copied to clipboard

Consider making `make-json` not destructive by default

Open TimothyBJacobs opened this issue 6 years ago • 5 comments

I was not expecting make-json to be destructive when first running the command and lost test data.

Should the default be changed to not purge? Or require WP_CLI::confirm if purge/no-purge isn't specified?

TimothyBJacobs avatar Feb 14 '19 16:02 TimothyBJacobs

I don't see much value in changing the default (again).

This options is about removing strings from the PO file that only occur in JavaScript files. Since we have the JSON translation files for JS-only strings, they are of no use in the PO file. That's why purge is the default.

It would help if you could explain your use case a bit more, beyond unexpectedness.

swissspidy avatar Feb 14 '19 17:02 swissspidy

I'm not sure what the actual use case is. It is unexpected that I can't run the same command twice.

In my case, I'd just created a sample translation file, and so after deleting the corresponding .json file, I had lost all of my "translations". In practice, you'd probably have a copy/backup of this file somewhere, but maybe not.

TimothyBJacobs avatar Feb 14 '19 17:02 TimothyBJacobs

It's better to keep them because it's a lot easier to update translation for PO files if you have some software to it (for example Poedit) and then only run the command to generate JSON translation files.

redoper1 avatar Oct 06 '20 12:10 redoper1

Good point.

Would it make sense to add a dedicated purge command or something? Because it's not ideal to then load the full PO file in memory when many of the translations are only used in JS.

swissspidy avatar Oct 06 '20 12:10 swissspidy

Yeah, maybe it would be good, but I don't know if it's needed when we can purge them by the same command only with the added parameter --purge instead of --no-purge to keep files intact.

redoper1 avatar Oct 16 '20 14:10 redoper1