Add formatted messages

only to components and things that will be going out in the first deploy
This commit is contained in:
Matthew Taylor 2015-10-16 11:04:01 -04:00
parent d0b22d0f97
commit c1de837595
6 changed files with 322 additions and 61 deletions

View file

@ -1,10 +1,20 @@
var React = require('react'); var React = require('react');
var ReactIntl = require('react-intl');
var defineMessages = ReactIntl.defineMessages;
var injectIntl = ReactIntl.injectIntl;
var Box = require('../box/box.jsx'); var Box = require('../box/box.jsx');
var Format = require('../../lib/format.js'); var Format = require('../../lib/format.js');
require('./activity.scss'); require('./activity.scss');
var defaultMessages = defineMessages({
whatsHappening: {
id: 'general.whatsHappening',
defaultMessage: 'What\s Happening?'
}
});
var Activity = React.createClass({ var Activity = React.createClass({
type: 'Activity', type: 'Activity',
propTypes: { propTypes: {
@ -16,10 +26,11 @@ var Activity = React.createClass({
}; };
}, },
render: function () { render: function () {
var formatMessage = this.props.intl;
return ( return (
<Box <Box
className="activity" className="activity"
title="What's Happening?"> title={formatMessage(defaultMessages.whatsHappening)}>
<ul> <ul>
{this.props.items.map(function (item) { {this.props.items.map(function (item) {
@ -39,4 +50,4 @@ var Activity = React.createClass({
} }
}); });
module.exports = Activity; module.exports = injectIntl(Activity);

View file

@ -1,4 +1,5 @@
var React = require('react'); var React = require('react');
var FormattedMessage = require('react-intl').FormattedMessage;
var LanguageChooser = require('../languagechooser/languagechooser.jsx'); var LanguageChooser = require('../languagechooser/languagechooser.jsx');
@ -11,53 +12,172 @@ var Footer = React.createClass({
<div className="inner"> <div className="inner">
<div className="lists"> <div className="lists">
<dl> <dl>
<dt>About</dt> <dt>
<dd><a href="/about/">About Scratch</a></dd> <FormattedMessage
<dd><a href="/parents/">For Parents</a></dd> id='general.about'
<dd><a href="/educators/">For Educators</a></dd> defaultMessage={'About'} />
<dd><a href="/info/credits/">Credits</a></dd> </dt>
<dd><a href="/jobs/">Jobs</a></dd> <dd><a href="/about/">
<dd><a href="http://wiki.scratch.mit.edu/wiki/Scratch_Press">Press</a></dd> <FormattedMessage
id='footer.about'
defaultMessage={'About Scratch'} />
</a></dd>
<dd><a href="/parents/">
<FormattedMessage
id='general.forParents'
defaultMessage={'For Parents'} />
</a></dd>
<dd><a href="/educators/">
<FormattedMessage
id='general.forEducators'
defaultMessage={'For Educators'} />
</a></dd>
<dd><a href="/info/credits/">
<FormattedMessage
id='general.credits'
defaultMessage={'Credits'} />
</a></dd>
<dd><a href="/jobs/">
<FormattedMessage
id='general.jobs'
defaultMessage={'Jobs'} />
</a></dd>
<dd><a href="http://wiki.scratch.mit.edu/wiki/Scratch_Press">
<FormattedMessage
id='general.press'
defaultMessage={'Press'} />
</a></dd>
</dl> </dl>
<dl> <dl>
<dt>Community</dt> <dt>
<dd><a href="/community_guidelines/">Community Guidelines</a></dd> <FormattedMessage
<dd><a href="/discuss/">Discussion Forums</a></dd> id='general.communityHeader'
<dd><a href="https://wiki.scratch.mit.edu/">Scratch Wiki</a></dd> defaultMessage={'Community'} />
<dd><a href="/statistics/">Statistics</a></dd> </dt>
<dd><a href="/community_guidelines/">
<FormattedMessage
id='general.guidelines'
defaultMessage={'Community Guidelines'} />
</a></dd>
<dd><a href="/discuss/">
<FormattedMessage
id='footer.discuss'
defaultMessage={'Discussion Forums'} />
</a></dd>
<dd><a href="https://wiki.scratch.mit.edu/">
<FormattedMessage
id='general.wiki'
defaultMessage={'Scratch Wiki'} />
</a></dd>
<dd><a href="/statistics/">
<FormattedMessage
id='general.statistics'
defaultMessage={'Statistics'} />
</a></dd>
</dl> </dl>
<dl> <dl>
<dt>Support</dt> <dt>
<dd><a href="/help/">Help Page</a></dd> <FormattedMessage
<dd><a href="/info/faq/">FAQ</a></dd> id='general.support'
<dd><a href="/scratch2download/">Offline Editor</a></dd> defaultMessage={'Support'} />
<dd><a href="/contact-us/">Contact Us</a></dd> </dt>
<dd><a href="https://secure.donationpay.org/codetolearn/">Donate</a></dd> <dd><a href="/help/">
<FormattedMessage
id='footer.help'
defaultMessage={'Help Page'} />
</a></dd>
<dd><a href="/info/faq/">
<FormattedMessage
id='general.faq'
defaultMessage={'FAQ'} />
</a></dd>
<dd><a href="/scratch2download/">
<FormattedMessage
id='general.offlineEditor'
defaultMessage={'Offline Editor'} />
</a></dd>
<dd><a href="/contact-us/">
<FormattedMessage
id='general.contactUs'
defaultMessage={'Contact Us'} />
</a></dd>
<dd><a href="https://secure.donationpay.org/codetolearn/">
<FormattedMessage
id='general.donate'
defaultMessage={'Donate'} />
</a></dd>
</dl> </dl>
<dl> <dl>
<dt>Legal</dt> <dt>
<dd><a href="/terms_of_use/">Terms of Use</a></dd> <FormattedMessage
<dd><a href="/privacy_policy/">Privacy Policy</a></dd> id='general.legal'
<dd><a href="/DMCA/">DMCA</a></dd> defaultMessage={'Legal'} />
</dt>
<dd><a href="/terms_of_use/">
<FormattedMessage
id='general.termsOfUse'
defaultMessage={'Terms of Use'} />
Terms of Use
</a></dd>
<dd><a href="/privacy_policy/">
<FormattedMessage
id='privacyPolicy'
defaultMessage={'Privacy Policy'} />
</a></dd>
<dd><a href="/DMCA/">
<FormattedMessage
id='general.dmca'
defaultMessage={'DMCA'} />
</a></dd>
</dl> </dl>
<dl> <dl>
<dt>Scratch Family</dt> <dt>
<dd><a href="http://scratched.gse.harvard.edu/">ScratchEd</a></dd> <FormattedMessage
<dd><a href="http://www.scratchjr.org/">ScratchJr</a></dd> id='footer.scratchFamily'
<dd><a href="http://day.scratch.mit.edu/">Scratch Day</a></dd> defaultMessage={'Scratch Family'} />
<dd><a href="/conference/">Scratch Conference</a></dd> </dt>
<dd><a href="http://www.scratchfoundation.org/">Scratch Foundation</a></dd> <dd><a href="http://scratched.gse.harvard.edu/">
<FormattedMessage
id='general.scratchEd'
defaultMessage={'ScratchEd'} />
</a></dd>
<dd><a href="http://www.scratchjr.org/">
<FormattedMessage
id='general.scratchJr'
defaultMessage={'ScratchJr'} />
</a></dd>
<dd><a href="http://day.scratch.mit.edu/">
<FormattedMessage
id='general.scratchday'
defaultMessage={'Scratch Day'} />
</a></dd>
<dd><a href="/conference/">
<FormattedMessage
id='general.scratchConference'
defaultMessage={'Scratch Conference'} />
</a></dd>
<dd><a href="http://www.scratchfoundation.org/">
<FormattedMessage
id='general.scratchFoundation'
defaultMessage={'Scratch Foundation'} />
</a></dd>
</dl> </dl>
</div> </div>
<LanguageChooser /> <LanguageChooser />
<div className="copyright"> <div className="copyright">
<p>Scratch is a project of the Lifelong Kindergarten Group at the MIT Media Lab</p> <p>
<FormattedMessage
id='general.copyright'
defaultMessage={
'Scratch is a project of the Lifelong Kindergarten Group at the MIT Media Lab'
} />
</p>
</div> </div>
</div> </div>
); );

View file

@ -1,4 +1,7 @@
var React = require('react'); var React = require('react');
var ReactIntl = require('react-intl');
var FormattedMessage = ReactIntl.FormattedMessage;
var FormattedHTMLMessage = ReactIntl.FormattedHTMLMessage;
var Modal = require('../modal/modal.jsx'); var Modal = require('../modal/modal.jsx');
require('./intro.scss'); require('./intro.scss');
@ -31,8 +34,12 @@ var Intro = React.createClass({
<div className="intro"> <div className="intro">
<div className="content"> <div className="content">
<h1> <h1>
Create stories, games, and animations<br /> <FormattedHTMLMessage
Share with others around the world id='intro.tagLine'
defaultMessage={
'Create stories, games, and animations<br /> ' +
'Share with others around the world'
} />
</h1> </h1>
<div className="sprites"> <div className="sprites">
<a className="sprite sprite-1" href="/projects/editor/?tip_bar=getStarted"> <a className="sprite sprite-1" href="/projects/editor/?tip_bar=getStarted">
@ -43,7 +50,11 @@ var Intro = React.createClass({
className="costume costume-2" className="costume costume-2"
src="//cdn.scratch.mit.edu/scratchr2/static/images/cat-b.png" /> src="//cdn.scratch.mit.edu/scratchr2/static/images/cat-b.png" />
<div className="circle"></div> <div className="circle"></div>
<div className="text">TRY IT OUT</div> <div className="text">
<FormattedMessage
id='intro.tryItOut'
defaultMessage='TRY IT OUT' />
</div>
</a> </a>
<a className="sprite sprite-2" href="/starter_projects/"> <a className="sprite sprite-2" href="/starter_projects/">
<img <img
@ -53,7 +64,11 @@ var Intro = React.createClass({
className="costume costume-2" className="costume costume-2"
src="//cdn.scratch.mit.edu/scratchr2/static/images/tera-b.png" /> src="//cdn.scratch.mit.edu/scratchr2/static/images/tera-b.png" />
<div className="circle"></div> <div className="circle"></div>
<div className="text">SEE EXAMPLES</div> <div className="text">
<FormattedMessage
id='intro.seeExamples'
defaultMessage='SEE EXAMPLES' />
</div>
</a> </a>
<a className="sprite sprite-3" href="#"> <a className="sprite sprite-3" href="#">
<img <img
@ -63,7 +78,11 @@ var Intro = React.createClass({
className="costume costume-2" className="costume costume-2"
src="//cdn.scratch.mit.edu/scratchr2/static/images/gobo-b.png" /> src="//cdn.scratch.mit.edu/scratchr2/static/images/gobo-b.png" />
<div className="circle"></div> <div className="circle"></div>
<div className="text">JOIN SCRATCH</div> <div className="text">
<FormattedMessage
id='intro.joinScratch'
defaultMessage='JOIN SCRATCH' />
</div>
<div className="text subtext">( it&rsquo;s free )</div> <div className="text subtext">( it&rsquo;s free )</div>
</a> </a>
</div> </div>
@ -73,9 +92,21 @@ var Intro = React.createClass({
projects shared projects shared
</div> </div>
<div className="links"> <div className="links">
<a href="/about/">ABOUT SCRATCH</a> <a href="/about/">
<a href="/educators/">FOR EDUCATORS</a> <FormattedMessage
<a className="last" href="/parents/">FOR PARENTS</a> id='intro.aboutScratch'
defaultMessage='ABOUT SCRATCH' />
</a>
<a href="/educators/">
<FormattedMessage
id='intro.forEducators'
defaultMessage='FOR EDUCATORS' />
</a>
<a className="last" href="/parents/">
<FormattedMessage
id='intro.forParents'
defaultMessage='FOR PARENTS' />
</a>
</div> </div>
</div> </div>
<div className="video"> <div className="video">

View file

@ -1,4 +1,6 @@
var React = require('react'); var React = require('react');
var FormattedMessage = require('react-intl').FormattedMessage;
var Input = require('../forms/input.jsx'); var Input = require('../forms/input.jsx');
var Button = require('../forms/button.jsx'); var Button = require('../forms/button.jsx');
@ -25,12 +27,28 @@ var Login = React.createClass({
return ( return (
<div className="login"> <div className="login">
<form onSubmit={this.handleSubmit}> <form onSubmit={this.handleSubmit}>
<label htmlFor="username">Username</label> <label htmlFor="username">
<FormattedMessage
id='general.username'
defaultMessage={'Username'} />
</label>
<Input type="text" ref="username" name="username" maxLength="30" /> <Input type="text" ref="username" name="username" maxLength="30" />
<label htmlFor="password">Password</label> <label htmlFor="password">
<FormattedMessage
id='general.password'
defaultMessage={'Password'} />
</label>
<Input type="password" ref="password" name="password" /> <Input type="password" ref="password" name="password" />
<Button className="submit-button white" type="submit">Sign in</Button> <Button className="submit-button white" type="submit">
<a className="right" href="/accounts/password_reset/">Forgot password?</a> <FormattedMessage
id='general.signIn'
defaultMessage={'Sign in'} />
</Button>
<a className="right" href="/accounts/password_reset/">
<FormattedMessage
id='login.forgotPassword'
defaultMessage={'Forgot Password?'} />
</a>
{error} {error}
</form> </form>
</div> </div>

View file

@ -1,5 +1,9 @@
var React = require('react');
var classNames = require('classnames'); var classNames = require('classnames');
var React = require('react');
var ReactIntl = require('react-intl');
var defineMessages = ReactIntl.defineMessages;
var FormattedMessage = ReactIntl.FormattedMessage;
var injectIntl = ReactIntl.injectIntl;
var xhr = require('xhr'); var xhr = require('xhr');
var Api = require('../../mixins/api.jsx'); var Api = require('../../mixins/api.jsx');
@ -12,6 +16,17 @@ var Session = require('../../mixins/session.jsx');
require('./navigation.scss'); require('./navigation.scss');
var defaultMessages = defineMessages({
messages: {
id: 'general.messages',
defaultMessage: 'Messages'
},
myStuff: {
id: 'general.myStuff',
defaultMessage: 'My Stuff'
}
});
var Navigation = React.createClass({ var Navigation = React.createClass({
type: 'Navigation', type: 'Navigation',
mixins: [ mixins: [
@ -95,11 +110,31 @@ var Navigation = React.createClass({
<ul> <ul>
<li className="logo"><a href="/"></a></li> <li className="logo"><a href="/"></a></li>
<li className="link create"><a href="/projects/editor">Create</a></li> <li className="link create"><a href="/projects/editor">
<li className="link explore"><a href="/explore?date=this_month">Explore</a></li> <FormattedMessage
<li className="link discuss"><a href="/discuss">Discuss</a></li> id="general.create"
<li className="link about"><a href="/about">About</a></li> defaultMessage={'Create'} />
<li className="link help"><a href="/help">Help</a></li> </a></li>
<li className="link explore"><a href="/explore?date=this_month">
<FormattedMessage
id="general.explore"
defaultMessage={'Explore'} />
</a></li>
<li className="link discuss"><a href="/discuss">
<FormattedMessage
id="general.discuss"
defaultMessage={'Discuss'} />
</a></li>
<li className="link about"><a href="/about">
<FormattedMessage
id="general.about"
defaultMessage={'About'} />
</a></li>
<li className="link help"><a href="/help">
<FormattedMessage
id="general.help"
defaultMessage={'Help'} />
</a></li>
<li className="search"> <li className="search">
<form action="/search/google_results" method="get"> <form action="/search/google_results" method="get">
@ -111,10 +146,20 @@ var Navigation = React.createClass({
</li> </li>
{this.state.session.user ? [ {this.state.session.user ? [
<li className="link right messages" key="messages"> <li className="link right messages" key="messages">
<a href="/messages/" title="Messages">Messages</a> <a
href="/messages/"
title={formatMessage(defaultMessages.messages)}
>
<FormattedMessage {...defaultMessages.messages} />
</a>
</li>, </li>,
<li className="link right mystuff" key="mystuff"> <li className="link right mystuff" key="mystuff">
<a href="/mystuff/" title="My Stuff">My Stuff</a> <a
href="/mystuff/"
title={formatMessage(defaultMessages.myStuff)}
>
<FormattedMessage {...defaultMessages.myStuff} />
</a>
</li>, </li>,
<li className="link right account-nav" key="account-nav"> <li className="link right account-nav" key="account-nav">
<a className="userInfo" href="#" onClick={this.handleAccountNavClick}> <a className="userInfo" href="#" onClick={this.handleAccountNavClick}>
@ -125,21 +170,43 @@ var Navigation = React.createClass({
as="ul" as="ul"
isOpen={this.state.accountNavOpen} isOpen={this.state.accountNavOpen}
onRequestClose={this.closeAccountNav}> onRequestClose={this.closeAccountNav}>
<li><a href={this.getProfileUrl()}>Profile</a></li> <li><a href={this.getProfileUrl()}>
<li><a href="/mystuff/">My Stuff</a></li> <FormattedMessage
<li><a href="/accounts/settings/">Account settings</a></li> id='general.profile'
defaultMessage={'Profile'} />
</a></li>
<li><a href="/mystuff/">
<FormattedMessage {...defaultMessages.myStuff} />
</a></li>
<li><a href="/accounts/settings/">
<FormattedMessage
id='general.accountSettings'
defaultMessage={'Account settings'} />
</a></li>
<li className="divider"> <li className="divider">
<a href="#" onClick={this.handleLogOut}>Sign out</a> <a href="#" onClick={this.handleLogOut}>
<FormattedMessage
id='navigation.signOut'
defaultMessage={'Sign out'} />
</a>
</li> </li>
</Dropdown> </Dropdown>
</li> </li>
] : [ ] : [
<li className="link right join" key="join"><a href="/join">Join Scratch</a></li>, <li className="link right join" key="join"><a href="/join">
<FormattedMessage
id='general.joinScratch'
defaultMessage={'Join Scratch'} />
</a></li>,
<li className="link right login-item" key="login"> <li className="link right login-item" key="login">
<a <a
href="#" href="#"
onClick={this.handleLoginClick} onClick={this.handleLoginClick}
className="ignore-react-onclickoutside">Sign In</a> className="ignore-react-onclickoutside">
<FormattedMessage
id='general.signIn'
defaultMessage={'Sign In'} />
</a>
<Dropdown <Dropdown
className="login-dropdown with-arrow" className="login-dropdown with-arrow"
isOpen={this.state.loginOpen} isOpen={this.state.loginOpen}
@ -156,4 +223,4 @@ var Navigation = React.createClass({
} }
}); });
module.exports = Navigation; module.exports = injectIntl(Navigation);

View file

@ -1,9 +1,23 @@
var React = require('react'); var React = require('react');
var ReactIntl = require('react-intl');
var defineMessages = ReactIntl.defineMessages;
var injectIntl = ReactIntl.injectIntl;
var Box = require('../box/box.jsx'); var Box = require('../box/box.jsx');
require('./news.scss'); require('./news.scss');
var defaultMessages = defineMessages({
scratchNews: {
id: 'news.scratchNews',
defaultMessage: 'Scratch News'
},
viewAll: {
id: 'general.viewAll',
defaultMessage: 'View All'
}
});
var News = React.createClass({ var News = React.createClass({
type: 'News', type: 'News',
propTypes: { propTypes: {
@ -18,8 +32,8 @@ var News = React.createClass({
return ( return (
<Box <Box
className="news" className="news"
title="Scratch News" title={formatMessage(defaultMessages.scratchNews)}
moreTitle="View All" moreTitle={formatMessage(defaultMessages.viewAll)}
moreHref="/news"> moreHref="/news">
<ul> <ul>
@ -40,4 +54,4 @@ var News = React.createClass({
} }
}); });
module.exports = News; module.exports = injectIntl(News);