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

Fix/translatable strings in theme json #8031

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from

Conversation

d-alleyne
Copy link

@d-alleyne d-alleyne commented Dec 20, 2024

Trac ticket: https://core.trac.wordpress.org/ticket/62728

This is a backport of WordPress/gutenberg#66675 and WordPress/gutenberg#68243


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props dalleyne.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link

Hi @d-alleyne! 👋

Thank you for your contribution to WordPress! 💖

It looks like this is your first pull request to wordpress-develop. Here are a few things to be aware of that may help you out!

No one monitors this repository for new pull requests. Pull requests must be attached to a Trac ticket to be considered for inclusion in WordPress Core. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description.

Pull requests are never merged on GitHub. The WordPress codebase continues to be managed through the SVN repository that this GitHub repository mirrors. Please feel free to open pull requests to work on any contribution you are making.

More information about how GitHub pull requests can be used to contribute to WordPress can be found in the Core Handbook.

Please include automated tests. Including tests in your pull request is one way to help your patch be considered faster. To learn about WordPress' test suites, visit the Automated Testing page in the handbook.

If you have not had a chance, please review the Contribute with Code page in the WordPress Core Handbook.

The Developer Hub also documents the various coding standards that are followed:

Thank you,
The WordPress Project

Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Copy link
Contributor

@audrasjb audrasjb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to go, thanks.

@@ -77,6 +77,20 @@
"name": "Space size name"
}
]
},
"dimensions": {
Copy link
Member

@oandregal oandregal Dec 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is making aspectRatios and shadow presets translatable at the block level (under settings/blocks/*), which doesn't fix the issue. Note that the Gutenberg PR WordPress/gutenberg#66675 adds shadow presets at the top level (under settings). Can we update this?

Copy link
Member

@oandregal oandregal Dec 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, there's the question of whether these presets are valid at the block level. If so, they should also be translatable there. These are the differences I see:

Preset Top Block
color.palette
color.gradients
color.duotone
dimensions.aspectRatios
shadow.presets
spacing.spacingSizes
typography.fontSizes
typography.fontFamilies

Copy link
Member

@oandregal oandregal Dec 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested every combination and this is what we need to do:

  • Duotone: add it to the block level.
  • Dimensions.aspectRatios: add it to the block level.
  • Shadow: no need to add it to the block level. It can't be defined there. If it is, the shadow UI component won't be rendered.

I've already prepared the PR in Gutenberg WordPress/gutenberg#68243 for these changes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference, the way I tested was by adding each of those presets in Gutenberg's theme.json file under a block (e.g.: settings.blocks.{paragraph/image/etc.}) and verify that those presets were used at that particular block. If that's true, we need the presets to be translatable; otherwise, we don't.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more general thought for reference, not need to do anything in this PR. After testing how presets work at the top vs block level, I realized they work differently. In general, the approach was that a preset defined at the block level would override the top-level ones. This is no longer true for some of them. I don't know if it's intentional or an oversight. These are the ones I've tested that work differently:

  • shadow: when presets are defined at the block level, the shadow UI doesn't show up
  • font families: when presets are defined at the block level, both the top and the block level presets are displayed
  • spacing sizes: when presets are defined at the block level, both general top spacing sizes and the block level ones are displayed

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