Localize Text skips text that starts or ends on a new line
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- php
- Domain
- internationalization
Research direction
Start in includes/create-theme/theme-locale.php, especially get_text_replacement_patterns_for_html() around lines 217-262. Check the affected HTML patterns against multiline headings and paragraphs; done means localized text is wrapped in esc_html_e() with surrounding whitespace trimmed, and templates with no other localized PHP are still moved into a pattern.
Written by the indexing model from the issue text.
Description
What happens
"Localize Text" skips text that starts or ends on a new line. The HTML patterns in get_text_replacement_patterns_for_html() have no s modifier, so . doesn't match a newline:
For example, this heading (from WooCommerce's Related Products markup) is exported unchanged:
<h2 class="wp-block-heading has-x-large-font-size">
Related products </h2>
The same happens to a paragraph like <p>\n\tNo products were found matching your selection.</p>. It affects every block type in that list, not just headings.
A side effect: when nothing in a template gets localized, the template isn't moved into a pattern either, because paternize_template() only runs when PHP was added.
Expected
The text is wrapped in esc_html_e(), with the surrounding whitespace trimmed.
Suggested fix
Add the s modifier to these patterns and trim the captured text before escaping it.
Drafted with AI assistance, verified by me against a theme exported with Create Block Theme and the source.
- Dominant language
- JavaScript
- Stars
- 418
- Forks
- 66
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from WordPress/create-block-theme
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
WordPress/create-block-theme#871 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
WordPress/create-block-theme#867 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
WordPress/create-block-theme#866 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
WordPress/create-block-theme#856 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 78/100
WordPress/create-block-theme#872 ·
All issues in WordPress/create-block-theme
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
Design only Leadership Survey SLFS
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
bcgov/digital-journeys#2293 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
tursodatabase/turso#9405 ·
Maintainers usually reply within 1 day
-
Toolkit
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
API Bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ProjectSidewalk/SidewalkWebpage#5556 ·
Maintainers usually reply within 1 day