mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-22 23:27:54 -05:00
Merge pull request #90 from mewtaylor/issue/update-language-footer
Use language dropdown form to change language
This commit is contained in:
commit
5d4dbf638c
2 changed files with 5 additions and 15 deletions
|
@ -3,6 +3,7 @@
|
|||
"/csrf_token/",
|
||||
"/fragment/",
|
||||
"/get_image/",
|
||||
"/i18n/setlang/",
|
||||
"/login_retry/",
|
||||
"/media/",
|
||||
"/session/",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
var classNames = require('classnames');
|
||||
var React = require('react');
|
||||
var ReactDOM = require('react-dom');
|
||||
|
||||
var Api = require('../../mixins/api.jsx');
|
||||
var languages = require('../../../languages.json');
|
||||
|
@ -24,20 +25,8 @@ var LanguageChooser = React.createClass({
|
|||
},
|
||||
onSetLanguage: function (e) {
|
||||
e.preventDefault();
|
||||
this.api({
|
||||
method: 'post',
|
||||
host: '',
|
||||
uri: '/i18n/setlang/',
|
||||
useCsrf: true,
|
||||
body: {
|
||||
language: e.target.value
|
||||
}
|
||||
|
||||
}, function (err, body) {
|
||||
if (body) {
|
||||
document.location.reload(true);
|
||||
}
|
||||
}.bind(this));
|
||||
this.setState({'choice': e.target.value});
|
||||
ReactDOM.findDOMNode(this.refs.languageForm).submit();
|
||||
},
|
||||
render: function () {
|
||||
var classes = classNames(
|
||||
|
@ -46,7 +35,7 @@ var LanguageChooser = React.createClass({
|
|||
);
|
||||
|
||||
return (
|
||||
<form ref="languageForm" className={classes}>
|
||||
<form ref="languageForm" className={classes} action="/i18n/setlang/" method="POST">
|
||||
<Select name="language" defaultValue={this.state.choice} onChange={this.onSetLanguage}>
|
||||
{Object.keys(this.props.languages).map(function (value) {
|
||||
return <option value={value} key={value}>
|
||||
|
|
Loading…
Reference in a new issue