diff --git a/server/proxies.json b/server/proxies.json index a19cf94a1..ae658a681 100644 --- a/server/proxies.json +++ b/server/proxies.json @@ -6,7 +6,6 @@ "/accounts/", "/csrf_token/", "/get_image/", - "/i18n/", "/session/", "/site-api/" ] diff --git a/src/components/footer/footer.jsx b/src/components/footer/footer.jsx index 751938496..396aa7ebd 100644 --- a/src/components/footer/footer.jsx +++ b/src/components/footer/footer.jsx @@ -1,43 +1,11 @@ var React = require('react'); -var log = require('../../log.js'); - -var Api = require('../../mixins/api.jsx'); -var CookieMixinFactory = require('../../mixins/cookieMixinFactory.jsx'); var LanguageChooser = require('../languagechooser/languagechooser.jsx'); require('./footer.scss'); var Footer = React.createClass({ type: 'Footer', - mixins: [ - Api, - // Provides useScratchlanguage - CookieMixinFactory('scratchlanguage', '/site-api/i18n/set-preferred-language/') - ], - getInitialState: function () { - return { - language: 'en' - }; - }, - componentDidMount: function () { - this.updateLanguage(); - }, - updateLanguage: function () { - this.useScratchlanguage(function (err, language) { - if (err) return log.error(err); - this.setState({language: language}); - }.bind(this)); - }, - handleSetLanguage: function (e) { - if (e) e.preventDefault(); - this.api({ - host: '', - uri: '/i18n/setlang/' - }, function (err, body) { - if (body) this.updateLanguage(); - }.bind(this)); - }, render: function () { return (
Scratch is a project of the Lifelong Kindergarten Group at the MIT Media Lab
diff --git a/src/components/languagechooser/languagechooser.jsx b/src/components/languagechooser/languagechooser.jsx index 6648b7385..42f9de2c7 100644 --- a/src/components/languagechooser/languagechooser.jsx +++ b/src/components/languagechooser/languagechooser.jsx @@ -1,39 +1,42 @@ var classNames = require('classnames'); - var React = require('react'); +var jar = require('../../lib/jar.js'); +var languages = require('../../../languages.json'); var Select = require('../forms/select.jsx'); require('./languagechooser.scss'); var LanguageChooser = React.createClass({ type: 'LanguageChooser', - propTypes: { - choice: React.PropTypes.string, - languages: React.PropTypes.object + getInitialState: function () { + return { + choice: window._locale + }; }, getDefaultProps: function () { return { - choice: 'en', - languages: require('./languages.json') + languages: languages }; }, + onSetLanguage: function (e) { + e.preventDefault(); + jar.set('scratchlanguage', e.target.value); + document.location.reload(true); + }, render: function () { var classes = classNames( 'language-chooser', this.props.className ); + return ( -