Better description for embed blocks#6124
Conversation
|
Nice, thank you for working on this! The change seem to be good for all the embed aliases: Though perhaps we could tune the description slightly so that it isn't as redundant. Maybe something like:
However this change doesn't look too good with the generic embed block: Can we make an exception for the generic embed (the one you get if you just insert "Embed") block, so it keeps its original description? |
|
@jasmussen Description updated Not sure if below approach is right should we check for 'Embed' or __( 'Embed' ) ? |
|
This looks great to me, thank you! I've added a review note for a quick glance at the code. Thanks again! |
blocks/library/embed/index.js
Outdated
|
|
||
| description: __( 'The Embed block allows you to easily add videos, images, tweets, audio, and other content to your post or page.' ), | ||
|
|
||
| description: 'Embed' !== title ? |
There was a problem hiding this comment.
I would rather pass block's name and perform this check based on it.
There was a problem hiding this comment.
I have another idea which is simpler: You can pass description for the base Embed block and compose it based on title for all other occurences:
export const settings = getEmbedBlockSettings( {
title: __( 'Embed' ),
description: __( 'The Embed block allows you to easily add videos, images, tweets, audio, and other content to your post or page.' ),
...and inside the getEmbedBlockSettings function:
description: description || __( `Paste URLs from ${ title } to embed the content in this block` ),There was a problem hiding this comment.
@gziolo this looks good compared to title or name safe & fewer code changes :)
have updated the PR
blocks/library/embed/index.js
Outdated
|
|
||
| description: __( 'The Embed block allows you to easily add videos, images, tweets, audio, and other content to your post or page.' ), | ||
|
|
||
| description: description || __( `Paste URLs from ${ title } to embed the content in this block` ), |
There was a problem hiding this comment.
I think this sentence should end with a period for consistency.
gziolo
left a comment
There was a problem hiding this comment.
I added the missing period. This looks great. Thanks for submitting this fix 👍
|
🎉 |
|
Note that this is a tricky change when it comes to i18n. In English, there is no inflexion in "Service" in the sentence "Paste URLs from Service to embed the content", but other languages might have them. As a general rule, it's very hard to respect i18n when generating strings of this kind, with names interpolated. A solution, although very cumbersome, would be to add strings for all these services in specific grammar cases, e.g.:
But I don't think the above would be practical at all, and would still likely break for some odd language that operates differently. (cf ablative) |
|
|
||
| description: __( 'The Embed block allows you to easily add videos, images, tweets, audio, and other content to your post or page.' ), | ||
|
|
||
| description: description || __( `Paste URLs from ${ title } to embed the content in this block.` ), |
There was a problem hiding this comment.
Because of how string extraction works, we cannot do variable string interpolation for translated strings.
This is the same as it is in PHP:
We should use a placeholder here, and wp.i18n.sprintf to do the variable replacement.
* Better description for embed blocksn * update description * Check based on description * Blocks: Add a period to the description of embed





Description
Fixes #6110
Generic description for embed blocks replaced with a personalized message by using embed title/aliases as suggested by @jasmussen
This embed block embeds content from ${ title }How Has This Been Tested?
npm run test-unitScreenshots (jpeg or gifs if applicable):
N/A
Types of changes
Non-breaking change
Checklist: