Link to pt-br downloads if locale is pt-br

This commit is contained in:
chrisgarrity 2017-09-19 08:19:36 -04:00
parent 4e49653fcc
commit b48411a8e4

View file

@ -3,6 +3,7 @@ var render = require('../../lib/render.jsx');
var FormattedHTMLMessage = require('react-intl').FormattedHTMLMessage;
var FormattedMessage = require('react-intl').FormattedMessage;
var injectIntl = require('react-intl').injectIntl;
var api = require('../../lib/api');
var Page = require('../../components/page/www/page.jsx');
@ -21,9 +22,13 @@ var Download = React.createClass({
};
},
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({
host: '',
uri: '/scratchr2/static/sa/version.xml',
uri: uri,
responseType: 'string'
}, function (err, body, res) {
if (err || res.statusCode >= 400) {
@ -39,12 +44,16 @@ var Download = React.createClass({
}.bind(this));
},
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) {
var downloadUrls = {
mac: '/scratchr2/static/sa/Scratch-'+ this.state.swfVersion + '.dmg',
mac105: '/scratchr2/static/sa/Scratch-'+ this.state.swfVersion + '.air',
windows: '/scratchr2/static/sa/Scratch-'+ this.state.swfVersion + '.exe',
linux: '/scratchr2/static/sa/Scratch-'+ this.state.swfVersion + '.air'
mac: downloadPath + this.state.swfVersion + '.dmg',
mac105: downloadPath + this.state.swfVersion + '.air',
windows: downloadPath + this.state.swfVersion + '.exe',
linux: downloadPath + this.state.swfVersion + '.air'
};
}
@ -233,4 +242,5 @@ var Download = React.createClass({
}
});
render(<Page><Download /></Page>, document.getElementById('app'));
var IntlDownload = injectIntl(Download);
render(<Page><IntlDownload /></Page>, document.getElementById('app'));