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

Section styles: support i18n for variations declared in theme.json or theme style variations #62552

Merged
merged 4 commits into from
Jun 14, 2024

Conversation

oandregal
Copy link
Member

@oandregal oandregal commented Jun 13, 2024

What?

This PR adds support for internationalizing the block style variations labels defined from a theme.json or a theme style variation (e.g.: styles/ember.json).

Why?

We want to enable internationalization of the block style variations defined from a theme.json or a theme style variation.

How?

Allow title to be provided when registering block style variations from theme.json or theme style variations (e.g.: styles/ember.json):

  • Update theme.json schema to allow title as a valid property
  • Update theme-i18n.json schema to signal title as a translatable property

Testing Instructions

In the theme.json of the theme, paste the following contents under styles.blocks.variations:

"myvariation": {
    "title": "My Variation",
    "blockTypes": ["core/group"],
    "color": {
        "background": "var(--wp--preset--color--base-2)"
    }
}
Without the title With the title
Captura de ecrã 2024-06-13, às 21 51 45 Captura de ecrã 2024-06-13, às 21 52 04

Note that the title was already permitted, so it didn't require any style registration/generation changes. This PR adds it as part of the schema used by editors for linting and makes it translatable.

Related work

Enabling the styles.blocks.variations.*.title property to be translatable requires:

@oandregal oandregal requested a review from spacedmonkey as a code owner June 13, 2024 14:43
@oandregal oandregal requested review from aaronrobertshaw and talldan and removed request for spacedmonkey June 13, 2024 14:43
@oandregal oandregal self-assigned this Jun 13, 2024
Copy link

github-actions bot commented Jun 13, 2024

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.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>

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

@oandregal oandregal added [Type] Bug An existing feature does not function as intended Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Jun 13, 2024
Copy link

This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress.

If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core GitHub repository soon after this pull request is merged.

If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack.

Thank you! ❤️

View changed files
❔ lib/theme-i18n.json

@oandregal oandregal added the Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Jun 13, 2024
Copy link

Flaky tests detected in 5ad228d.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9501765632
📝 Reported issues:

@oandregal
Copy link
Member Author

@aaronrobertshaw I haven't found any docs for this, so I haven't update them. It'd be useful to incorporate examples (in the devnote of the feature, theme.json docs, etc.) that include the title to raise awareness among users.

@oandregal
Copy link
Member Author

oandregal commented Jun 13, 2024

I'd like to hold on merging until I have the tests passing in the related PR for the i18n-command at wp-cli/i18n-command#405

Copy link
Contributor

@aaronrobertshaw aaronrobertshaw left a comment

Choose a reason for hiding this comment

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

LGTM 👍

This tests as advertised. I also like that it helps make it clearer that the keys should be lowercase slugs even if we can't enforce that 100% due to BC.

I haven't found any docs for this, so I haven't update them

There's a dev note comment and draft post for it.

When updating the dev note and writing the docs, it will be worth mentioning that the title will only be used from the first source the style gets registered from. That is, if the variation is defined within the main theme.json and redefined in a theme style variation, the title set in the main theme.json is what will be used. It is not overridden.

Updating the handbook documentation is still in progress but bug fixes have taken priority during this 6.6 beta period. I'll hopefully return to it and the dev note next week.

schemas/json/theme.json Outdated Show resolved Hide resolved
@oandregal
Copy link
Member Author

The related work at wp-cli/i18n-command#405 is working fine when executing manually. There're some issues with the behat tests that shouldn't block this PR from landing (actually, after backporting this to core the tests there should be fixed).

@oandregal oandregal enabled auto-merge (squash) June 14, 2024 08:23
@oandregal oandregal merged commit c009a43 into trunk Jun 14, 2024
62 checks passed
@oandregal oandregal deleted the update/i18n-for-variations-in-theme-json branch June 14, 2024 08:24
@github-actions github-actions bot added this to the Gutenberg 18.6 milestone Jun 14, 2024
patil-vipul pushed a commit to patil-vipul/gutenberg that referenced this pull request Jun 17, 2024
…or theme style variations (WordPress#62552)

Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
ellatrix pushed a commit that referenced this pull request Jun 18, 2024
…or theme style variations (#62552)

Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
ellatrix pushed a commit that referenced this pull request Jun 18, 2024
…or theme style variations (#62552)

Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
@ellatrix
Copy link
Member

I just cherry-picked this PR to the wp/6.6-beta-3 branch to get it included in the next release: 0f53d7b

@ellatrix ellatrix added Backported to WP Core Pull request that has been successfully merged into WP Core and removed Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Jun 18, 2024
ellatrix pushed a commit that referenced this pull request Jun 18, 2024
…or theme style variations (#62552)

Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backported to WP Core Pull request that has been successfully merged into WP Core Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Bug An existing feature does not function as intended
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants