From 770e1dc71104617f0dfb694cd8dd7d22ff9727b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Thu, 13 Jun 2024 22:32:10 +0200 Subject: [PATCH 1/5] Update schema --- assets/theme-i18n.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/assets/theme-i18n.json b/assets/theme-i18n.json index 82f89bd..989b887 100644 --- a/assets/theme-i18n.json +++ b/assets/theme-i18n.json @@ -73,6 +73,15 @@ } } }, + "styles": { + "blocks": { + "variations": { + "*": { + "title": "Style variation name" + } + } + } + }, "customTemplates": [ { "title": "Custom template name" From ebc79f4172fc69f84716885c3c50cbbc3e8cd293 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Thu, 13 Jun 2024 22:32:16 +0200 Subject: [PATCH 2/5] Update test --- features/makepot.feature | 45 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/features/makepot.feature b/features/makepot.feature index 4df6200..853e4e3 100644 --- a/features/makepot.feature +++ b/features/makepot.feature @@ -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" + """ + Scenario: Extract strings from the blocks section of theme.json files Given an empty foo-theme directory And a foo-theme/theme.json file: From 21ffdeed75807f3c93f1a0e0c02a67e98b380843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Fri, 14 Jun 2024 08:58:31 +0200 Subject: [PATCH 3/5] Add test for files within styles/ --- features/makepot.feature | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/features/makepot.feature b/features/makepot.feature index 853e4e3..2b34a03 100644 --- a/features/makepot.feature +++ b/features/makepot.feature @@ -3775,6 +3775,18 @@ Feature: Generate a POT file of a WordPress project } } } + }, + "styles": { + "blocks": { + "variations": { + "myVariation": { + "title": "My variation", + "color": { + "background": "grey" + } + } + } + } } } """ @@ -3792,6 +3804,18 @@ Feature: Generate a POT file of a WordPress project } } } + }, + "styles": { + "blocks": { + "variations": { + "otherVariation": { + "title": "My other variation", + "color": { + "background": "grey" + } + } + } + } } } """ @@ -3807,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 From c918b7ab629439fb5caf731985bc0fbadafde361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Fri, 14 Jun 2024 16:51:33 +0200 Subject: [PATCH 4/5] Remove invalid comma in theme.json provided to the behat test --- features/makepot.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/makepot.feature b/features/makepot.feature index 2b34a03..ca480bb 100644 --- a/features/makepot.feature +++ b/features/makepot.feature @@ -3692,7 +3692,7 @@ Feature: Generate a POT file of a WordPress project "color": { "duotone": [ { "slug": "dark-grayscale", "name": "Dark grayscale", "colors": [] } - ], + ] } }, "styles": { From 8465789f2539fd50cba3933670f21120762af4be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Fri, 14 Jun 2024 17:11:04 +0200 Subject: [PATCH 5/5] Use proper output string --- features/makepot.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/makepot.feature b/features/makepot.feature index ca480bb..bcc9f57 100644 --- a/features/makepot.feature +++ b/features/makepot.feature @@ -3724,7 +3724,7 @@ Feature: Generate a POT file of a WordPress project And the foo-theme/foo-theme.pot file should contain: """ msgctxt "Style variation name" - msgid "My style variation" + msgid "My variation" """ Scenario: Extract strings from the blocks section of theme.json files