こんにちは、私はちょうどあなたのテーマを購入し、英語と中国語にGutenbergブロックを翻訳する方法を知っていただきたいと思います、ありがとうございました。 (Loco translateで翻訳に失敗しました。）
You could use translation plugins like WPML, TranslatePress for contents. SWELL theme itself may not be fully translatable, but perhaps you could translate some strings with Loco Translate.
I just tried to use .po file to convert to json file through wp-cli, but the part of gutenberg block was not translated successfully, could you give me more tips?
I used the wp-cli command: wp i18n make-json po-filename.po --allow-root
but the part of gutenberg block was not translated successfully,
Could you attach a screenshot mentioning which block and which part you are exactly referring to?
Sorry, I have never used Loco Translate and I am not sure about the cause either.
I am not loading the translation files for the scripts for each block, only for 'swell_blocks' (/build/blocks/index.js).
This means that `wp_set_script_translations()` only needs to be done once.
If you can run the npm command on your computer, the following method would be easiest. This is an example of generating a translation file in traditional Chinese.
- Open the directory where you installed WordPress and go to `wp-content/themes/swell/languages`.
- Copy `en_US.po` and create `zh_CN.po`.
- Use this file for translation; you may want to use a tool such as Poedit.
- Open a terminal and move to the `languages` directory.
- Generate a JSON translation file for Gutenberg. Use npx and execute the following command:
`npx email@example.com zh_CN.po swell-zh_CN-swell_blocks.json -f jed `
- `swell-zh_CN-swell_blocks.json` file will be generated in the languages directory.
- Change the site language to Traditional Chinese and confirm that the translation has been applied to the SWELL blocks.