Link to pt-br downloads if locale is pt-br (#1558)

* Link to pt-br downloads if locale is pt-br
This commit is contained in:
chrisgarrity 2017-09-19 11:56:30 -04:00 committed by GitHub
parent 4fa3c0f761
commit 5f48fc13e8

View file

@ -3,6 +3,7 @@ var render = require('../../lib/render.jsx');
var FormattedHTMLMessage = require('react-intl').FormattedHTMLMessage; var FormattedHTMLMessage = require('react-intl').FormattedHTMLMessage;
var FormattedMessage = require('react-intl').FormattedMessage; var FormattedMessage = require('react-intl').FormattedMessage;
var injectIntl = require('react-intl').injectIntl;
var api = require('../../lib/api'); var api = require('../../lib/api');
var Page = require('../../components/page/www/page.jsx'); var Page = require('../../components/page/www/page.jsx');
@ -13,7 +14,7 @@ var SubNavigation = require('../../components/subnavigation/subnavigation.jsx');
require('./download.scss'); require('./download.scss');
require('../../components/forms/button.scss'); require('../../components/forms/button.scss');
var Download = React.createClass({ var Download = injectIntl(React.createClass({
type: 'Download', type: 'Download',
getInitialState: function () { getInitialState: function () {
return { return {
@ -21,9 +22,13 @@ var Download = React.createClass({
}; };
}, },
componentDidMount: function () { componentDidMount: function () {
var uri = '/scratchr2/static/sa/version.xml';
if (this.props.intl.locale === 'pt-br') {
uri = '/scratchr2/static/sa/pt-br/version.xml';
}
api({ api({
host: '', host: '',
uri: '/scratchr2/static/sa/version.xml', uri: uri,
responseType: 'string' responseType: 'string'
}, function (err, body, res) { }, function (err, body, res) {
if (err || res.statusCode >= 400) { if (err || res.statusCode >= 400) {
@ -39,12 +44,16 @@ var Download = React.createClass({
}.bind(this)); }.bind(this));
}, },
render: function () { render: function () {
var downloadPath = '/scratchr2/static/sa/Scratch-';
if (this.props.intl.locale === 'pt-br') {
downloadPath = '/scratchr2/static/sa/pt-br/Scratch-';
}
if (this.state.swfVersion.length > 0 && this.state.swfVersion !== -1) { if (this.state.swfVersion.length > 0 && this.state.swfVersion !== -1) {
var downloadUrls = { var downloadUrls = {
mac: '/scratchr2/static/sa/Scratch-'+ this.state.swfVersion + '.dmg', mac: downloadPath + this.state.swfVersion + '.dmg',
mac105: '/scratchr2/static/sa/Scratch-'+ this.state.swfVersion + '.air', mac105: downloadPath + this.state.swfVersion + '.air',
windows: '/scratchr2/static/sa/Scratch-'+ this.state.swfVersion + '.exe', windows: downloadPath + this.state.swfVersion + '.exe',
linux: '/scratchr2/static/sa/Scratch-'+ this.state.swfVersion + '.air' linux: downloadPath + this.state.swfVersion + '.air'
}; };
} }
@ -231,6 +240,6 @@ var Download = React.createClass({
</div> </div>
); );
} }
}); }));
render(<Page><Download /></Page>, document.getElementById('app')); render(<Page><Download /></Page>, document.getElementById('app'));