-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Tweaks following npm package updates for Beta 3 #5441
Conversation
Co-Authored-By: Felix Arntz <felix-arntz@leaves-and-love.net>
On Latest Posts block. Co-Authored-By: Felix Arntz <felix-arntz@leaves-and-love.net>
$trimmed_excerpt .= '… <a href="' . esc_url( $post_link ) . '" rel="noopener noreferrer">'; | ||
$trimmed_excerpt .= sprintf( | ||
/* translators: 1: A URL to a post, 2: The static string "Read more", 3: The post title only visible to screen readers. */ | ||
__( '… <a href="%1$s" rel="noopener noreferrer">%2$s<span class="screen-reader-text">: %3$s</span></a>' ), | ||
esc_url( $post_link ), | ||
__( 'Read more' ), | ||
/* translators: %s: The post title only visible to screen readers */ | ||
__( 'Continue reading <span class="screen-reader-text">%s</span>' ), | ||
esc_html( $title ) | ||
); | ||
$trimmed_excerpt .= '</a>'; |
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.
@swissspidy, pinging you here as these changes have moved from #5439 (comment) to here 🙇
Edit: Sorry, just saw your comment on the other PR! Copying over for completeness:
Rule of thumb is to avoid string concatenation like in this suggestion.
The ellipsis should be part of the translatable string, which means keeping the a tag in there, too. But ses, the „Read more“ should be in there as well and not added via a placeholder.
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.
cc. @ramonjd @andrewserong for your thoughts here as you were involved in the original GB PR.
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.
Again, no string concatenation please. The ellipsis AND the link tag should pe part of the translatable string.
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.
Strings targeted for screen readers have this comment in core:
/* translators: Hidden accessibility text. */
And combined with a placeholder, something like this:
/* translators: Hidden accessibility text. %s: Post 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.
Thanks @swissspidy! I've updated this in 6e74cd9 by removing the string concatenation and moving "Read more" into the translatable string. I think this is closer to your suggestions.
@kebbet, thanks for this, I've also updated the comment to this:
/* translators: 1: A URL to a post, 2: Hidden accessibility text: Post title */
Does this make sense?
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.
Thanks for the feedback here, folks! And to @mikachan for updating the block 🙇🏻
Just to provide context, the original idea was to use the already-translated "Read more" - so thanks for the clarification on that approach.
I've got a PR going in Gutenberg to sync the changes from this patch. I'll give it a final update after this PR closes (should there be any further changes).
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.
Thanks for opening the follow up PR @mikachan!
@@ -152,10 +152,9 @@ function render_block_core_latest_posts( $attributes ) { | |||
if ( $excerpt_length <= $block_core_latest_posts_excerpt_length ) { | |||
$trimmed_excerpt = substr( $trimmed_excerpt, 0, -11 ); | |||
$trimmed_excerpt .= sprintf( | |||
/* translators: 1: A URL to a post, 2: The static string "Read more", 3: The post title only visible to screen readers. */ | |||
__( '… <a href="%1$s" rel="noopener noreferrer">%2$s<span class="screen-reader-text">: %3$s</span></a>' ), | |||
/* translators: The static string "Read more". %1$s: A URL to a post, %2$s: Hidden accessibility text: Post 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.
There's some description in here that probably shouldn't be, I think these comments should only include the description of the placeholders.
/* translators: The static string "Read more". %1$s: A URL to a post, %2$s: Hidden accessibility text: Post title */ | |
/* translators: 1: URL to a post, 2: post 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.
Indeed!
I recommend checking the handbook for best practices like that
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 static string "Read more"
here as the "Read more" string is now part of this single placeholder. Is it OK if this isn't described in the comments, or is there a different way to do this?
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.
Oh, I see from the examples here that any translatable text doesn't need to be described specifically, only the variables. Makes sense, the suggestion above works 🎉
Although as per @kebbet's suggestion, should we keep the "Hidden accessibility text" comment?
/* translators: 1: A URL to a post, 2: The static string "Read more", 3: The post title only visible to screen readers. */ | ||
__( '… <a href="%1$s" rel="noopener noreferrer">%2$s<span class="screen-reader-text">: %3$s</span></a>' ), | ||
/* translators: The static string "Read more". %1$s: A URL to a post, %2$s: Hidden accessibility text: Post title */ | ||
__( '… <a href="%1$s" rel="noopener noreferrer">Read more<span class="screen-reader-text">: %2$s</span></a>' ), |
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.
Curious why we're using "Read more: {title}" here, as it reads a bit weird. Most existing core themes have been using something like "Continue reading {title}", which makes for a better reading flow.
Also see #5439 (comment)
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'm not sure why this wording has been chosen, so pinging @ramonjd @andrewserong to hopefully help here.
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.
Thanks for the ping. "Read more" has been a feature of this block for a long time and I didn't want to change things up too much. So the basic reason was backwards compatibility.
That meant deciding how to structure the string so that it made sense grammatically. A semi-colon is fine.
The other option could have been "Read more of", or about, but I discarded the superfluous preposition.
I'm happy for the wording to change completely if folks think it best. As mentioned, my only intention was to avoid the situation where existing sites install 6.4, and are then left wondering why the "Read more" link text has changed.
P.S.: I'll make a note to backport any changes made here back to Gutenberg. Thanks a lot for helping to tidy this up, everyone!
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.
Yeah the main reason the post title is added after the read more is so that when a screen reader provides a list of links on the page there is some context to each link and not just a bunch of "read more"s. In those circumstances something like "continue reading" won't make any more sense than "read more".
In any case this is probably not something to be changed during Beta as it's not, strictly speaking, a bug 😄
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.
Based on the feedback on this and the previous PR, these changes LGTM!
/* translators: 1: A URL to a post, 2: The static string "Read more", 3: The post title only visible to screen readers. */ | ||
__( '… <a href="%1$s" rel="noopener noreferrer">%2$s<span class="screen-reader-text">: %3$s</span></a>' ), | ||
/* translators: The static string "Read more". %1$s: A URL to a post, %2$s: Hidden accessibility text: Post title */ | ||
__( '… <a href="%1$s" rel="noopener noreferrer">Read more<span class="screen-reader-text">: %2$s</span></a>' ), |
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.
Yeah the main reason the post title is added after the read more is so that when a screen reader provides a list of links on the page there is some context to each link and not just a bunch of "read more"s. In those circumstances something like "continue reading" won't make any more sense than "read more".
In any case this is probably not something to be changed during Beta as it's not, strictly speaking, a bug 😄
I've tested the latest comments and it LGTM. I was wondering whether, instead of trimming the last 11 chars in the event of finding if ( $excerpt_length <= $block_core_latest_posts_excerpt_length ) {
$excerpt_more = sprintf(
/* translators: 1: A URL to a post, 2: Hidden accessibility text: Post title */
__( '… <a href="%1$s" rel="noopener noreferrer">Read more<span class="screen-reader-text">: %2$s</span></a>' ),
esc_url( $post_link ),
esc_html( $title )
);
$trimmed_excerpt = wp_trim_words( $trimmed_excerpt, $excerpt_length, $excerpt_more );
} But looking into it, we're doing nearly the same thing , I will add that, while working on the translation, I found this block to be a little inconsistent in the way it presents trimmed excerpts in the editor and the frontend. I think it's due to the priority ( EditorFrontendUsing Related issue: WordPress/gutenberg#33027 |
Oh, I just realised these changes are to block-library files, so they need to be done in Gutenberg and followed by another package update. We shouldn't commit this changeset to core because it will be wiped the next time the packages are built 😅 I can put up a PR! |
I have one here if you wanna highjack it 👍🏻 |
I just did WordPress/gutenberg#55184 lol |
* Site Editor Styles Screen: Fix dancing styles previews (#55183) * Pulling across changes from WordPress/wordpress-develop#5441 (#55181) Removed var * Add `aria-label` attribute to navigation block only when it is open (#54816) * Add `aria-label` only when is open * Remove unnecessary `label` property in edit * Escape translation * Move navigation context to `wp_json_encode` * Add `wp_json_encode` flags * Paste: fix MS Word list paste (#55127) * Paste: fix MS Word list paste * Match mso-list:Ignore * Fix inline paste * Fix scrollbars on pattern transforms (#55069) * Fix scrollbars on pattern transforms * Fix single pattern previews * Improve classname semantics * Remove modal title * Reset styles on window resize (#55077) Co-authored-by: Ricardo Artemio Morales <ric.morales22@gmail.com> --------- Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com> Co-authored-by: Ramon <ramonjd@users.noreply.github.com> Co-authored-by: Mario Santos <34552881+SantosGuillamot@users.noreply.github.com> Co-authored-by: Ella <4710635+ellatrix@users.noreply.github.com> Co-authored-by: Daniel Richards <daniel.richards@automattic.com> Co-authored-by: Ricardo Artemio Morales <ric.morales22@gmail.com>
Thanks everyone for your help and feedback here! 🚀 |
Trac ticket: https://core.trac.wordpress.org/ticket/59411
This is a follow-up to #5439, as some review comments were missed just before commit.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.