-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather pass block's name
and perform this check based on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gziolo will give that a try
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, thanks 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this sentence should end with a period for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of how string extraction works, we cannot do variable string interpolation for translated strings.
This is the same as it is in PHP:
https://codex.wordpress.org/I18n_for_WordPress_Developers#Placeholders
We should use a placeholder here, and wp.i18n.sprintf
to do the variable replacement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* 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-unit
Screenshots (jpeg or gifs if applicable):
N/A
Types of changes
Non-breaking change
Checklist: