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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/wp-includes/theme-i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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

"aspectRatios": [
{
"name": "Aspect ratio name"
}
]
},
"shadow": {
"presets": [
{
"name": "Shadow name"
}
]
}
}
}
Expand Down
Loading