Skip to content

Commit

Permalink
Merge pull request #405 from oandregal/add/theme-json-variation-title
Browse files Browse the repository at this point in the history
theme.json: find `title` string within `styles.blocks.variations`
  • Loading branch information
swissspidy authored Jun 15, 2024
2 parents 373ec88 + 8465789 commit 24caafc
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
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 @@ -3717,6 +3717,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 variation"
"""

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 @@ -3765,6 +3810,18 @@ Feature: Generate a POT file of a WordPress project
}
}
}
},
"styles": {
"blocks": {
"variations": {
"myVariation": {
"title": "My variation",
"color": {
"background": "grey"
}
}
}
}
}
}
"""
Expand All @@ -3782,6 +3839,18 @@ Feature: Generate a POT file of a WordPress project
}
}
}
},
"styles": {
"blocks": {
"variations": {
"otherVariation": {
"title": "My other variation",
"color": {
"background": "grey"
}
}
}
}
}
}
"""
Expand All @@ -3797,10 +3866,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

0 comments on commit 24caafc

Please sign in to comment.