Skip to content

Translate "description" field from theme.json#408

Merged
swissspidy merged 1 commit intowp-cli:mainfrom
ramonjd:add/description-field-to-theme-json
Jul 3, 2024
Merged

Translate "description" field from theme.json#408
swissspidy merged 1 commit intowp-cli:mainfrom
ramonjd:add/description-field-to-theme-json

Conversation

@ramonjd
Copy link
Contributor

@ramonjd ramonjd commented Jul 1, 2024

This PR:

  • adds a new field "description" to theme.json top level to translate
  • updates the expectation to existing behat tests

Important

A WordPress Core PR exists to add the "description" key to src/wp-includes/theme-i18n.json. This has not yet been committed.

TODO

  • Check test instructions (this is my first PR)
  • Have the Core PR tested and committed

Context

A "description" key was added to theme.json in WordPress/gutenberg#45242

The Gutenberg PR was synced to Core in WordPress/wordpress-develop#4687

Unfortunately, a corresponding entry to the theme.json i18n schema was not part of the change.

Core trac ticket: https://core.trac.wordpress.org/ticket/61543

Testing

Set up

brew install jq mysql
brew service start mysql
mysql_secure_installation
sudo mysql -u root -p

# MySQL Session
CREATE DATABASE IF NOT EXISTS `wp_cli_test`;
CREATE USER 'wp_cli_test'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password1';
GRANT ALL PRIVILEGES ON wp_cli_test.* TO "wp_cli_test"@"localhost";
\q

Before running any of the test (manual or automatic), make sure to set the THEME_JSON_SOURCE to '' (empty string) so the ThemeJsonExtractor picks the the local backup file with the changes at assets/theme-i18n.json.

Automated tests:

composer install
composer behat -- features/makepot.feature

Manual tests:

Create a new directory called foo-theme that contains a theme.json file with the following contents:

{
    "description": "My style variation description"
}

Run vendor/bin/wp i18n make-pot foo-theme

Verify that there's a foo-theme/foo-theme.pot file and that the "My style variation description" string is present as well as its context "Style variation description".

You should see something like:

msgctxt "Style variation description"
msgid "My style variation description"
msgstr ""

@oandregal
Copy link
Contributor

I approved the core PR and this PR is also working well for me.

I'll leave @swissspidy comment on this, but my understanding is that we should merge the core PR and right after merge this one.

@swissspidy
Copy link
Member

Correct. Otherwise tests are failing, as you can see now :-)

@ramonjd ramonjd marked this pull request as ready for review July 1, 2024 23:38
@ramonjd ramonjd requested a review from a team as a code owner July 1, 2024 23:38
@oandregal
Copy link
Contributor

The core PR has been merged as of WordPress/wordpress-develop@2930212

@swissspidy swissspidy added this to the 2.6.2 milestone Jul 3, 2024
@swissspidy swissspidy added the command:i18n-make-pot Related to 'i18n make-pot' command label Jul 3, 2024
@swissspidy swissspidy merged commit 53518a1 into wp-cli:main Jul 3, 2024
@ramonjd
Copy link
Contributor Author

ramonjd commented Jul 3, 2024

Thanks for the help, folks 🙇🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:i18n-make-pot Related to 'i18n make-pot' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants