Skip to content
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

Merged
merged 6 commits into from
Oct 25, 2018
Merged

Make preview placeholder text translatable #10880

merged 6 commits into from
Oct 25, 2018

Conversation

swissspidy
Copy link
Member

@swissspidy swissspidy commented Oct 21, 2018

Description

This PR addresses #10874 by making the Please wait… Generating preview. text translatable.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

Fixes #7725.

@ocean90
Copy link
Member

ocean90 commented Oct 21, 2018

This is the same as #3301 which got closed. Maybe you can address the feedback in your PR?

@swissspidy
Copy link
Member Author

Using Lodash's _.escape function now as suggested in that PR.

@jasmussen jasmussen requested a review from a team October 22, 2018 13:08
Copy link
Member

@aduth aduth left a 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&hellip;' ) }</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&hellip;</p>
<p>Generating preview.</p>
<p>${ escape( __( 'Please wait&hellip;' ) ) }</p>
Copy link
Member

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&hellip;' ); is Please wait&amp;hellip;, which will effectively print to the screen as Please wait&hellip;.

@chrisvanpatten
Copy link
Contributor

Relates to #10896 too.

@aduth
Copy link
Member

aduth commented Oct 22, 2018

We may need to use decodeEntities regardless of solution, it appears.

https://github.com/WordPress/gutenberg/tree/master/packages/html-entities

@swissspidy
Copy link
Member Author

@aduth Thanks for your feedback! I updated the code to use renderToString() and decodeEntities() now, and it works like a charm.

@jasmussen
Copy link
Contributor

Early bird gets the worm, right? :D

If this gets in before #10896, I will carefully and gladly rebase.

@swissspidy swissspidy requested a review from jasmussen October 23, 2018 10:15
@jasmussen
Copy link
Contributor

Nice! Thank you for handling the conflict ;)

I think this is good to ship when Andrew thumbs up!

packages/editor/CHANGELOG.md Show resolved Hide resolved
</svg>
<p>Generating preview...</p>
<p>{ decodeEntities( __( 'Generating preview&hellip;' ) ) }</p>
Copy link
Member

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>

Copy link
Member Author

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 &hellip; is better for translators, but I'll change it.

Copy link
Member

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' .

&hellip; is what I've personally used for consistency with other translated strings, but also 🤷‍♂️ can't see why it makes much a difference.

@swissspidy
Copy link
Member Author

Fixed merge conflict after #10953.

@swissspidy swissspidy requested a review from ocean90 October 23, 2018 15:32
@jasmussen jasmussen added this to the 4.2 milestone Oct 24, 2018
@youknowriad youknowriad modified the milestones: 4.2, 4.1 - UI freeze Oct 24, 2018
@youknowriad youknowriad added this to the 4.2 milestone Oct 24, 2018
@gziolo gziolo added the Internationalization (i18n) Issues or PRs related to internationalization efforts label Oct 25, 2018
@gziolo gziolo merged commit 0df454f into master Oct 25, 2018
@gziolo gziolo deleted the fix/preview-i18n branch October 25, 2018 08:06
antpb pushed a commit to antpb/gutenberg that referenced this pull request Oct 26, 2018
* Make preview placeholder text translatable

* Escape i18n strings since they are directly added to markup

* Use renderToString() and decodeEntities()

* Address feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internationalization (i18n) Issues or PRs related to internationalization efforts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants