wp-cli / i18n-command

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

Translate "description" field from theme.json #408

Closed ramonjd closed 1 month ago

ramonjd commented 1 month ago

This PR:

[!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

Context

A "description" key was added to theme.json in https://github.com/WordPress/gutenberg/pull/45242

The Gutenberg PR was synced to Core in https://github.com/WordPress/wordpress-develop/pull/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 commented 1 month ago

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 commented 1 month ago

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

oandregal commented 1 month ago

The core PR has been merged as of https://github.com/WordPress/wordpress-develop/commit/2930212ff6bf6619d026f525ceab2719c5229597

ramonjd commented 1 month ago

Thanks for the help, folks 🙇🏻