WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.48k stars 4.18k forks source link

Translatable strings from `lib/theme.json` are not being extracted for translation #66027

Open yuliyan opened 2 weeks ago

yuliyan commented 2 weeks ago

Description

The strings from the lib/theme.json are not being extracted for translation, likely due to wp i18n make-pot command being limited to only scanning the theme.json file in the root of the plugin/theme or the JSON files in styles/*.json.

As a results some of the strings, such as the aspect ratio options, the drop shadow presets, etc., are not available for translation in the GlotPress project and thus the strings appear untranslated in the block editor (see the attached screenshots).

Step-by-step reproduction instructions

  1. Download the plugin locally.
  2. Make POT with wp i18n make-pot ..
  3. Inspect the generated gutenberg.pot file to confirm strings from lib/theme.json are not being extracted.

Screenshots, screen recording, code snippet

Aspect ratio options: Image

Drop shadow presets: Image

Environment info

Please confirm that you have searched existing issues in the repo.

Please confirm that you have tested with all plugins deactivated except Gutenberg.

d-alleyne commented 1 day ago

Hi @swissspidy, upon reviewing this issue, we discovered that limiting the extractor to only work with the top-level theme.json has caused the bug. Could you provide some insight into why this change was implemented in this commit: https://github.com/wp-cli/i18n-command/commit/345eb7a88443d4db63a8d8e7c7aac935fb197392? We are considering loosening this restriction but are concerned about potential side-effects you might be aware of.

swissspidy commented 1 day ago

Well, it's simple. theme.json are for block themes and must live in the root folder of a block theme. With this in place, the string extraction is much faster as there is no point in scanning every other directory for such a file.

Plugins normally don't include a theme.json file. Gutenberg is the exception because the format is developed here.

I'd rather suggest Gutenberg moving the file location, that would be the simpler solution.