Skip to content

Block Directory: Make downloadable block item labels translatable. - #81237

Merged
jorgefilipecosta merged 2 commits into
trunkfrom
fix/block-directory-untranslatable-labels
Aug 6, 2026
Merged

Block Directory: Make downloadable block item labels translatable.#81237
jorgefilipecosta merged 2 commits into
trunkfrom
fix/block-directory-untranslatable-labels

Conversation

@jorgefilipecosta

Copy link
Copy Markdown
Member

Fixes the four downloadable block item labels in the Block Directory that could not be translated.

The getDownloadableBlockLabel helper in downloadable-block-list-item passes its format strings straight to sprintf without wrapping them in __(). The translator comments are in place, but because the strings never go through an i18n function they are not extracted for translation and always render in English. These are the "Install %s.", "Add %s.", "Installing %s." and "Retry installing %s." labels used for the tooltip and the accessible label of each result in the inserter's Block Directory search.

To fix this we wrap the four format strings in __(), matching the _n() call already used for the rated variant in the same function. A sweep of the repository did not turn up this pattern anywhere else — the remaining unwrapped sprintf calls are developer-facing error messages, HTML id attributes, or code samples, which should not be translated.

Testing Instructions

  1. Run npm run test:unit -- packages/block-directory and verify the tests pass.
  2. In the post editor, open the inserter and search for a block that is not installed, so Block Directory results appear.
  3. Hover a result and verify its tooltip and accessible label still read "Install . …" as before.
  4. Verify the four strings in packages/block-directory/src/components/downloadable-block-list-item/index.js are wrapped in __() with their translator comments, so they get extracted for translation.

AI usage disclosure: fix and description drafted with AI assistance and reviewed by me.

@jorgefilipecosta jorgefilipecosta added [Type] Bug An existing feature does not function as intended [Feature] Block Directory Related to the Block Directory, a repository of block plugins labels Aug 5, 2026
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

Size Change: -9 B (0%)

Total Size: 7.81 MB

📦 View Changed
Filename Size Change
build/scripts/block-directory/index.min.js 44.1 kB -9 B (-0.02%)

compressed-size-action

@jorgefilipecosta
jorgefilipecosta force-pushed the fix/block-directory-untranslatable-labels branch from 04f63db to ea3240b Compare August 5, 2026 20:42

@Mamaduka Mamaduka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good catch, @jorgefilipecosta!

It's odd that these went unnoticed for so long.

@jorgefilipecosta
jorgefilipecosta merged commit a96cd78 into trunk Aug 6, 2026
46 checks passed
@jorgefilipecosta
jorgefilipecosta deleted the fix/block-directory-untranslatable-labels branch August 6, 2026 10:17
@github-actions github-actions Bot added this to the Gutenberg 23.8 milestone Aug 6, 2026
talldan pushed a commit that referenced this pull request Aug 6, 2026
…81237)

Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
amitraj2203 pushed a commit that referenced this pull request Aug 10, 2026
…81237)

Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
shail-mehta pushed a commit that referenced this pull request Aug 12, 2026
…81237)

Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Block Directory Related to the Block Directory, a repository of block plugins [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants