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

Translate title field from theme.json #306

Merged
merged 8 commits into from
Mar 31, 2022
Merged

Translate title field from theme.json #306

merged 8 commits into from
Mar 31, 2022

Conversation

oandregal
Copy link
Contributor

@oandregal oandregal commented Mar 10, 2022

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 Translate name field from theme.json Mar 10, 2022
assets/theme-i18n.json Outdated Show resolved Hide resolved
@oandregal oandregal changed the title Translate name field from theme.json Translate title field from theme.json Mar 31, 2022
@oandregal
Copy link
Contributor Author

@swissspidy this is ready for review.

@swissspidy
Copy link
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
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
Contributor Author

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

@oandregal
Copy link
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
Member

assets/theme-i18n.json Outdated Show resolved Hide resolved
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants