Skip to content
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

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

Merged
merged 4 commits into from
Mar 31, 2022
Merged

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

merged 4 commits into from
Mar 31, 2022

Conversation

oandregal
Copy link
Contributor

This PR is a continuation of #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:

  • Check out this PR locally and cd to the directory.
  • composer install
  • Create a new directory called foo-theme that contains a styles directory.
  • Within the styles directory create a my-style.json file with the following contents:
{
  "settings": {
    "color": {
      "palette": [ { "name": "My color", "slug": "slug", "color": "value" } ]
    }
  }
}
  • Run vendor/bin/wp i18n make-pot foo-theme
  • Verify that there's a foo-theme/foo-theme.pot file and that the "My color" string is present as well as its context "Color name". You should see something like:
msgctxt "Color name"
msgid "My color"
msgstr ""

@oandregal oandregal requested a review from a team as a code owner March 31, 2022 16:17
@oandregal
Copy link
Contributor Author

cc @swissspidy this is the continuation of #306

@oandregal
Copy link
Contributor Author

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: #306 needs to be merged to fix that warning.

@swissspidy
Copy link
Member

Merged #306 now

@swissspidy swissspidy merged commit 6c0fcdb into wp-cli:main Mar 31, 2022
@oandregal oandregal deleted the add/global-style-variations branch April 1, 2022 08:05
@schlessera schlessera added this to the 2.2.14 milestone Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants