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

theme.json: find title string within styles.blocks.variations #405

Merged
merged 5 commits into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
9 changes: 9 additions & 0 deletions assets/theme-i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@
}
}
},
"styles": {
"blocks": {
"variations": {
"*": {
"title": "Style variation name"
}
}
}
},
"customTemplates": [
{
"title": "Custom template name"
Expand Down
79 changes: 79 additions & 0 deletions features/makepot.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3682,6 +3682,51 @@ Feature: Generate a POT file of a WordPress project
msgid "My style variation"
"""

Scenario: Extract strings from the styles.blocks.variations section of theme.json files
Given an empty foo-theme directory
And a foo-theme/theme.json file:
"""
{
"version": "1",
"settings": {
"color": {
"duotone": [
{ "slug": "dark-grayscale", "name": "Dark grayscale", "colors": [] }
]
}
},
"styles": {
"blocks": {
"variations": {
"variationSlug": {
"title": "My variation",
"color": {
"background": "grey"
}
}
}
}
}
}
"""

When I try `wp i18n make-pot foo-theme`
Then STDOUT should be:
"""
Success: POT file successfully generated.
"""
And the foo-theme/foo-theme.pot file should exist
And the foo-theme/foo-theme.pot file should contain:
"""
msgctxt "Duotone name"
msgid "Dark grayscale"
"""
And the foo-theme/foo-theme.pot file should contain:
"""
msgctxt "Style variation name"
msgid "My style variation"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This output doesn't match the input (My variation). Fixed at 8465789

"""

Scenario: Extract strings from the blocks section of theme.json files
Given an empty foo-theme directory
And a foo-theme/theme.json file:
Expand Down Expand Up @@ -3730,6 +3775,18 @@ Feature: Generate a POT file of a WordPress project
}
}
}
},
"styles": {
"blocks": {
"variations": {
"myVariation": {
"title": "My variation",
"color": {
"background": "grey"
}
}
}
}
}
}
"""
Expand All @@ -3747,6 +3804,18 @@ Feature: Generate a POT file of a WordPress project
}
}
}
},
"styles": {
"blocks": {
"variations": {
"otherVariation": {
"title": "My other variation",
"color": {
"background": "grey"
}
}
}
}
}
}
"""
Expand All @@ -3762,10 +3831,20 @@ Feature: Generate a POT file of a WordPress project
msgctxt "Color name"
msgid "Black"
"""
And the foo-theme/foo-theme.pot file should contain:
"""
msgctxt "Style variation name"
msgid "My variation"
"""
And the foo-theme/foo-theme.pot file should not contain:
"""
msgid "White"
"""
And the foo-theme/foo-theme.pot file should not contain:
"""
msgctxt "Style variation name"
msgid "My other variation"
"""

Scenario: Extract strings from the patterns directory
Given an empty foo-theme/patterns directory
Expand Down
Loading