-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Post Comments Block: Allow placeholders to reorder items in translations #40849
Conversation
Size Change: -461 B (0%) Total Size: 1.23 MB
ℹ️ View Unchanged
|
/* translators: %s: Post title. */ | ||
sprintf( __( 'One response to %s' ), postTitle ) |
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 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 Carlos! LGTM
If possible, I'd vote for getting this into 6.0:
|
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.
A couple of questions but if the answer is no it looks good to me.
</p> | ||
</div> | ||
|
||
<div className="reply"> | ||
<a | ||
className="comment-reply-link" | ||
href="#top" | ||
aria-label="Reply to A WordPress Commenter" | ||
aria-label={ __( | ||
'Reply to A WordPress Commenter' |
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.
Could this use the following to avoid new strings?
/* translators: Comment reply button text. %s: Comment author name. */
sprintf(
__( 'Reply to %s' ),
__( 'A WordPress Commenter' )
);
</span> | ||
{ createInterpolateElement( | ||
__( | ||
'<b><a>A WordPress Commenter</a></b> <span>says:</span>' |
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.
Is it possible to use something like this to closer match the WP Core strings?
sprintf(
/* translators: %s: Comment author link. */
__( '%s <span>says:</span>' ),
sprintf( '<cite><a>%s</a></cite>', __( 'A WordPress Commenter' ) )
)
I think the answer might be no because of how createInterpolateElement()
is intended to work but I'd rather ask.
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.
If we don't add any class to the translation string, createInterpolateElement()
works fine. 🎉
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.
Nice use of createInterpolateElement
and sprintf
😄
I cherry-picked this to wp/6.0 branch to be included in WordPress 6.0 RC2 later today 4013384 |
What?
With the Comments Placeholder task, we created some translatable fields. These previous ones had the phrase order hardcoded, so the translators could not select in what order the phrases are constructed.
Why?
Because we love the fact that WordPress is in almost all languages ❤️
How?
By using provided functions. I'm afraid that new strings will appear for the translations.
Before:
{ __( 'One response to' ) } “{ postTitle }”
-> Translator can only change the first sentence, being mandatory to show the post title at the end.After:
sprintf( __( 'One response to %s' ), postTitle )
-> Translator can move %s wherever they need to.Testing Instructions
1.) Translate the new strings and check that you can use the order you need.
Screenshots or screencast