From 4914ba6d85b77795df82f36f999ba1dd3c175c5d Mon Sep 17 00:00:00 2001 From: Matthew Taylor Date: Tue, 22 Mar 2016 11:00:37 -0400 Subject: [PATCH 1/2] Use `formatNumber` to localize project count `toLocaleString()` is not supported in Safari, but react-intl has a polyfill, and so it is. This also localized the intro description string, which wasn't previously. This also fixes #366 by doing as @rschamp suggested and checking if the count is the default count before setting the value. --- src/components/intro/intro.jsx | 13 ++++++------- src/views/splash/l10n.json | 2 ++ src/views/splash/splash.jsx | 11 +++++++++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/components/intro/intro.jsx b/src/components/intro/intro.jsx index 3764c5c6c..66468606e 100644 --- a/src/components/intro/intro.jsx +++ b/src/components/intro/intro.jsx @@ -25,9 +25,11 @@ var Intro = React.createClass({ 'intro.joinScratch': 'JOIN SCRATCH', 'intro.seeExamples': 'SEE EXAMPLES', 'intro.tagLine': 'Create stories, games, and animations
Share with others around the world', - 'intro.tryItOut': 'TRY IT OUT' + 'intro.tryItOut': 'TRY IT OUT', + 'intro.description': 'A creative learning community with ' + + 'over 13 million projects shared' }, - projectCount: 10569070, + projectCount: 13000000, session: {} }; }, @@ -113,11 +115,8 @@ var Intro = React.createClass({ onRequestClose={this.closeRegistration} onRegistrationDone={this.completeRegistration} /> -
- A creative learning community with - {this.props.projectCount.toLocaleString()} - projects shared -
+
{this.props.messages['intro.aboutScratch']} diff --git a/src/views/splash/l10n.json b/src/views/splash/l10n.json index b8e4cea7e..802611330 100644 --- a/src/views/splash/l10n.json +++ b/src/views/splash/l10n.json @@ -18,6 +18,8 @@ "intro.seeExamples": "SEE EXAMPLES", "intro.tagLine": "Create stories, games, and animations
Share with others around the world", "intro.tryItOut": "TRY IT OUT", + "intro.description": "A creative learning community with {value} projects shared", + "intro.defaultDescription": "A creative learning community with over 13 million projects shared", "news.scratchNews": "Scratch News", diff --git a/src/views/splash/splash.jsx b/src/views/splash/splash.jsx index b20bddb2d..2eebbb0bd 100644 --- a/src/views/splash/splash.jsx +++ b/src/views/splash/splash.jsx @@ -29,7 +29,7 @@ var Splash = injectIntl(React.createClass({ ], getInitialState: function () { return { - projectCount: 'over 13 million', // gets the shared project count + projectCount: 13000000, // gets the shared project count activity: [], // recent social actions taken by users someone is following news: [], // gets news posts from the scratch Tumblr featuredCustom: {}, // custom homepage rows, such as "Projects by Scratchers I'm Following" @@ -326,8 +326,9 @@ var Splash = injectIntl(React.createClass({ var emailConfirmationStyle = {width: 500, height: 330, padding: 1}; var homepageCacheState = this.getHomepageRefreshStatus(); - var formatMessage = this.props.intl.formatMessage; var formatHTMLMessage = this.props.intl.formatHTMLMessage; + var formatNumber = this.props.intl.formatNumber; + var formatMessage = this.props.intl.formatMessage; var messages = { 'general.viewAll': formatMessage({id: 'general.viewAll'}), 'news.scratchNews': formatMessage({id: 'news.scratchNews'}), @@ -343,6 +344,12 @@ var Splash = injectIntl(React.createClass({ 'intro.tagLine': formatHTMLMessage({id: 'intro.tagLine'}), 'intro.tryItOut': formatMessage({id: 'intro.tryItOut'}) }; + if (this.state.projectCount === this.getInitialState().projectCount) { + messages['intro.description'] = formatHTMLMessage({id: 'intro.defaultDescription'}); + } else { + var count = formatNumber(this.state.projectCount); + messages['intro.description'] = formatHTMLMessage({id: 'intro.description'}, {value: count}); + } return (
From 9a2a923b7b53f08ea0f75e07852981978163ecf2 Mon Sep 17 00:00:00 2001 From: Matthew Taylor Date: Tue, 22 Mar 2016 12:09:51 -0400 Subject: [PATCH 2/2] Remove `projectCount` from intro.jsx thanks @rschamp! --- src/components/intro/intro.jsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/components/intro/intro.jsx b/src/components/intro/intro.jsx index 66468606e..07e58f281 100644 --- a/src/components/intro/intro.jsx +++ b/src/components/intro/intro.jsx @@ -13,9 +13,6 @@ Modal.setAppElement(document.getElementById('view')); var Intro = React.createClass({ type: 'Intro', - propTypes: { - projectCount: React.PropTypes.number - }, getDefaultProps: function () { return { messages: { @@ -29,7 +26,6 @@ var Intro = React.createClass({ 'intro.description': 'A creative learning community with ' + 'over 13 million projects shared' }, - projectCount: 13000000, session: {} }; },