Skip to content

Translate title field from theme.json - #306

Merged
swissspidy merged 8 commits into
wp-cli:mainfrom
oandregal:add/name-field-to-theme-json
Mar 31, 2022
Merged

Translate title field from theme.json#306
swissspidy merged 8 commits into
wp-cli:mainfrom
oandregal:add/name-field-to-theme-json

Conversation

@oandregal

@oandregal oandregal commented Mar 10, 2022

Copy link
Copy Markdown
Contributor

Related #254 #292

In WordPress/gutenberg#39322 and WordPress/gutenberg#39715 the Gutenberg plugin has added a new translatable field to theme.json files, which will be part of WordPress 6.0.

This PR does a few things:

  • Adds the new field to the local i18n schema.
  • Updates the code so top-level keys are picked up for translation.
  • Updates the code so strings are translatable (in addition to leaf arrays, as it works now).

How to test

Automated tests:

composer behat -- features/makepot.feature

Manual test:

  • Check out this PR locally and cd to the directory.
  • composer install
  • Comment this line in the ThemeJsonExtractor class, so the command uses the local backup file (assets/theme-i18n.json).
  • Create a new directory called foo-theme that contains a theme.json file with the following contents:
{
    "title": "My style variation"
}
  • 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" string is present as well as its context "Style variation name". You should see something like:
msgctxt "Style variation name"
msgid "My style variation"
msgstr ""
@oandregal
oandregal requested a review from a team as a code owner March 10, 2022 14:12
@oandregal oandregal changed the title Translate name field from theme json Mar 10, 2022
Comment thread assets/theme-i18n.json Outdated
@oandregal oandregal changed the title Translate name field from theme.json Mar 31, 2022
@oandregal

Copy link
Copy Markdown
Contributor Author

@swissspidy this is ready for review.

@swissspidy

Copy link
Copy Markdown
Member

Change looks good, but note that Behat tests are now failing.

Is it on someone's radar to update theme-i18n.json in core as well?

@oandregal

Copy link
Copy Markdown
Contributor Author

The functional tests are failing because they're using the schema pulled from https://develop.svn.wordpress.org/trunk/src/wp-includes/theme-i18n.json to extract the strings, which doesn't have the title key yet. I'm preparing PRs for WordPress trunk and Gutenberg.

@oandregal

Copy link
Copy Markdown
Contributor Author

WordPress trunk PR at WordPress/wordpress-develop#2483
Gutenberg PR at WordPress/gutenberg#39936

@oandregal

Copy link
Copy Markdown
Contributor Author

The changes to the i18n schema in Gutenberg and WordPress trunk have been deployed a couple of hours ago. However, the file at https://develop.svn.wordpress.org/trunk/src/wp-includes/theme-i18n.json doesn't yet have them despite it saying that it's at Revision 53038 (the one that was deployed). Perhaps develop.svn.wordpress.org is something we only update nightly? I'll check tomorrow.

@swissspidy

Copy link
Copy Markdown
Member
Comment thread assets/theme-i18n.json Outdated
oandregal and others added 2 commits March 31, 2022 17:02
Co-authored-by: Pascal Birchler <pascal.birchler@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants