wp-cli / i18n-command

Provides internationalization tools for WordPress projects.
MIT License
96 stars 52 forks source link

Look for `theme.json` files in the `styles` directory of a theme #311

Closed oandregal closed 2 years ago

oandregal commented 2 years ago

This PR is a continuation of https://github.com/wp-cli/i18n-command/pull/306

It adds supports for looking for translatable strings in JSON files within the styles directory of a theme. Unlike the top-level theme.json file we don't lock any names in this case: any JSON file within the styles folder is a candidate we should consider.

How to test

Automated tests:

composer behat -- features/makepot.feature

Manual test:

{
  "settings": {
    "color": {
      "palette": [ { "name": "My color", "slug": "slug", "color": "value" } ]
    }
  }
}
msgctxt "Color name"
msgid "My color"
msgstr ""
oandregal commented 2 years ago

cc @swissspidy this is the continuation of https://github.com/wp-cli/i18n-command/pull/306

oandregal commented 2 years ago

The behat tests are now throwing the following warning (hence they fail):

PHP Warning: Invalid argument supplied for foreach() in src/ThemeJsonExtractor.php on line 209

This warning also happens in main.

The reason for this warning is that the i18n schema used to translate theme.json files (see) has been updated this morning. However, the code that interprets it has not been updated it yet: https://github.com/wp-cli/i18n-command/pull/306 needs to be merged to fix that warning.

swissspidy commented 2 years ago

Merged #306 now