0

I correctly internationalized a javascript file from wp theme folder.

Now I would like to know if Wordpress team plans to propose a CLI to update json without losing existing translation.

It seems that developers are currently talking about the add of "update-json" command CLI. But isn't there already one or more command cli that can read a file (.json), compare its content with existing content of other .json file with the same extension and instantiation, copy the difference and duplicate it in another file or rewrite in existing file ?

Obviously I'm thinking of several dozen strings to be translated,adding ten lines can be done manually without any problem.

In the same way as updating the .po file (cli = update-po). Perhaps using this command : diff, cp, and others ?

4
  • Can't you just run make-json again? Sep 21 at 1:47
  • Unfortunately not. It rewrite existing {text-domain}-{lang_COUNTRY}-{md5}.json. Or it is possible to create a new json file using a new name (to ot rewrite existing) -> copy strings from those not yet translated in this new json file -> paste them to official .json file -> finally, translate these sentences.
    – imagIne
    Sep 21 at 9:06
  • So for the moment the only way to do this is to rename the .json file by replacing the {md5} with the id of the script (in my case "main-action"). So I have that : {text-domain}-{lang_country}{main-action}.json I use this command to format/display the code with indentation (pretty-print ) wp i18n make-json en_GB.po --pretty-print from the "languages" folder. 1/2
    – imagIne
    Sep 21 at 10:11
  • 2/2 I copy and paste the content I haven't yet translated into my json file named with {md5} at the end and translate. Beware of possible conflicts: the duplicated file with the script id ($handle of enqueued script): {text-domain}-{lang_country}-{id-script}.json is also recognised by wp i18n and always translates the javascript content correctly. So I suggest deleting this file so that only {text-domain}-{lang_country}-{md5}.json remains.
    – imagIne
    Sep 21 at 10:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.