-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update i18n docs to use make-json command from wp-cli #15303
Conversation
@mkaz I've followed your instructions. I have a plugin that create custom blocks which is divided into 11 .js files that contain translation strings. For the last step, when I use wp-cli to convert the po file to JSON, it creates 11 plugin-eo-[md5].json files. Is there an extra step to merge all these files into one? |
@dianeco The language files are directly related to the JavaScript files, so when a JS file is enqueued WP will use the related language files when needed. So you can combine the JS together prior to translations, or it is fine to have all the additional language files. |
@mkaz Thanks for your answer. I use create-guten-block which combine the files into one but the command |
@dianeco Make sure you use the correct text domain throughout all of your PHP and JavaScript code. This is a best practice and required for string extraction to work properly across the board. |
@swissspidy Thanks for your reply. Yes I use the correct text domain in the JavaScript code. The process described above works fine when I use it on the dev files (but it creates a json file for each js file). |
That sounds like your production JS files is all minified, so instead of having |
@swissspidy Can you take a look at this PR? I'd love to get the instructions to use make-json instead of po2json updated and out to users. Thanks! |
Co-Authored-By: Pascal Birchler <pascal.birchler@gmail.com>
Description
Updates the Internationalization documentation recommending to use the wp-cli make-json command to generate the necessary json file needed for translations.
This replaces the instructions to use the npm po2json module, it is simpler for a user to use only the wp-cli tool which is also used earlier in the documentation for creating the pot files.
There was a bug fixed in wp-cli wp-cli/i18n-command#146
Fixes #14093
How has this been tested?
Follow instructions in documentation to confirm JSON file is created and translations work.
Types of changes
Documentation.