From 398f9cb95ac6608cc53da84fdbaa053e13b112ed Mon Sep 17 00:00:00 2001 From: Matthew Taylor Date: Thu, 7 Jan 2016 09:57:34 -0500 Subject: [PATCH] Move component strings into views MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Handle localization and string loading in views only. Components should just of default text, but not the actual text for the page itself – all text handling should be at the view level. --- src/components/intro/intro.jsx | 46 +++++++++++------------------- src/components/news/news.jsx | 27 ++++++------------ src/components/welcome/welcome.jsx | 31 ++++++++++---------- src/l10n.json | 16 +---------- src/views/splash/l10n.json | 17 ++++++++++- src/views/splash/splash.jsx | 41 ++++++++++++++++++++++++-- 6 files changed, 95 insertions(+), 83 deletions(-) diff --git a/src/components/intro/intro.jsx b/src/components/intro/intro.jsx index c8930a52f..101501627 100644 --- a/src/components/intro/intro.jsx +++ b/src/components/intro/intro.jsx @@ -1,8 +1,5 @@ var omit = require('lodash.omit'); var React = require('react'); -var ReactIntl = require('react-intl'); -var FormattedMessage = ReactIntl.FormattedMessage; -var FormattedHTMLMessage = ReactIntl.FormattedHTMLMessage; var Modal = require('../modal/modal.jsx'); var Registration = require('../registration/registration.jsx'); @@ -18,7 +15,16 @@ var Intro = React.createClass({ }, getDefaultProps: function () { return { - projectCount: 10569070 + projectCount: 10569070, + messages: { + 'intro.aboutScratch': 'ABOUT SCRATCH', + 'intro.forEducators': 'FOR EDUCATORS', + 'intro.forParents': 'FOR PARENTS', + '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' + } }; }, getInitialState: function () { @@ -52,13 +58,7 @@ var Intro = React.createClass({ return (
-

- ' + - 'Share with others around the world' - } /> +

diff --git a/src/components/news/news.jsx b/src/components/news/news.jsx index e5dc54643..63ef7aa71 100644 --- a/src/components/news/news.jsx +++ b/src/components/news/news.jsx @@ -1,23 +1,9 @@ var React = require('react'); -var ReactIntl = require('react-intl'); -var defineMessages = ReactIntl.defineMessages; -var injectIntl = ReactIntl.injectIntl; var Box = require('../box/box.jsx'); require('./news.scss'); -var defaultMessages = defineMessages({ - scratchNews: { - id: 'news.scratchNews', - defaultMessage: 'Scratch News' - }, - viewAll: { - id: 'general.viewAll', - defaultMessage: 'View All' - } -}); - var News = React.createClass({ type: 'News', propTypes: { @@ -25,16 +11,19 @@ var News = React.createClass({ }, getDefaultProps: function () { return { - items: require('./news.json') + items: require('./news.json'), + messages: { + 'general.viewAll': 'View All', + 'news.scratchNews': 'Scratch News' + } }; }, render: function () { - var formatMessage = this.props.intl.formatMessage; return (