-
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
Make preview placeholder text translatable #10880
Conversation
This is the same as #3301 which got closed. Maybe you can address the feedback in your PR? |
Using Lodash's |
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 renderToString
is probably the easiest / safest way to go here. Might need to concatenate the style tag separately.
let markup = renderToString(
<div className="editor-post-preview-button__interstitial-message">
<p>{ __( 'Please wait…' ) }</p>
<p>{ __( 'Generating preview.' ) }</p>
</div>
);
markup += `
<style>
body {
margin: 0;
}
.editor-post-preview-button__interstitial-message {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
width: 100vw;
}
p {
text-align: center;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}
</style>`;
@@ -90,8 +90,8 @@ export class PostPreviewButton extends Component { | |||
|
|||
const markup = ` | |||
<div class="editor-post-preview-button__interstitial-message"> | |||
<p>Please wait…</p> | |||
<p>Generating preview.</p> | |||
<p>${ escape( __( 'Please wait…' ) ) }</p> |
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.
The result of _.escape( 'Please wait…' );
is Please wait&hellip;
, which will effectively print to the screen as Please wait…
.
Relates to #10896 too. |
We may need to use https://github.com/WordPress/gutenberg/tree/master/packages/html-entities |
@aduth Thanks for your feedback! I updated the code to use |
Early bird gets the worm, right? :D If this gets in before #10896, I will carefully and gladly rebase. |
Nice! Thank you for handling the conflict ;) I think this is good to ship when Andrew thumbs up! |
</svg> | ||
<p>Generating preview...</p> | ||
<p>{ decodeEntities( __( 'Generating preview…' ) ) }</p> |
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.
We can use the unicode character (…) here instead of calling decodeEntities
.
<p>{ __( 'Generating preview…' ) }</p>
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.
Last time I checked ESLint threw a warning because of that, but it seems that it's not the case anymore 🤷♂️
I'd also argue that …
is better for translators, but I'll change 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.
The ESLint would have been for 'three dots' .
…
is what I've personally used for consistency with other translated strings, but also 🤷♂️ can't see why it makes much a difference.
Fixed merge conflict after #10953. |
* Make preview placeholder text translatable * Escape i18n strings since they are directly added to markup * Use renderToString() and decodeEntities() * Address feedback
Description
This PR addresses #10874 by making the
Please wait… Generating preview.
text translatable.Checklist:
Fixes #7725.