mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-30 10:58:23 -05:00
generalize pdf check
thanks @rschamp! fyi, I left it in cards only because I'm not sure that we really do this `(English)` thing anywhere else.
This commit is contained in:
parent
ffc1e8d0ca
commit
87ce6db1cd
1 changed files with 36 additions and 12 deletions
|
@ -11,6 +11,12 @@ require('./cards.scss');
|
|||
|
||||
var Cards = injectIntl(React.createClass({
|
||||
type: 'Cards',
|
||||
pdfLocaleMismatch: function (locale, pdf, englishPdf) {
|
||||
if (pdf === englishPdf && locale.indexOf('en') !== 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
render: function () {
|
||||
var locale = this.props.intl.locale || 'en';
|
||||
var formatMessage = this.props.intl.formatMessage;
|
||||
|
@ -51,8 +57,11 @@ var Cards = injectIntl(React.createClass({
|
|||
<img src="/svgs/pdf-icon-ui-blue.svg" alt="" className='pdf-icon' />
|
||||
<FormattedMessage id='cards.viewCard' />
|
||||
{(
|
||||
formattedLinks['cards.starterLink'] === englishLinks['cards.starterLink'] &&
|
||||
locale.indexOf('en') === -1
|
||||
this.pdfLocaleMismatch(
|
||||
locale,
|
||||
formattedLinks['cards.starterLink'],
|
||||
englishLinks['cards.starterLink']
|
||||
)
|
||||
) ? [
|
||||
<span> <FormattedMessage id='cards.english' /></span>
|
||||
] : []}
|
||||
|
@ -67,8 +76,11 @@ var Cards = injectIntl(React.createClass({
|
|||
<img src="/svgs/pdf-icon-ui-blue.svg" alt="" className='pdf-icon' />
|
||||
<FormattedMessage id='cards.viewCard' />
|
||||
{(
|
||||
formattedLinks['cards.nameLink'] === englishLinks['cards.nameLink'] &&
|
||||
locale.indexOf('en') === -1
|
||||
this.pdfLocaleMismatch(
|
||||
locale,
|
||||
formattedLinks['cards.nameLink'],
|
||||
englishLinks['cards.nameLink']
|
||||
)
|
||||
) ? [
|
||||
<span> (<FormattedMessage id='cards.english' />)</span>
|
||||
] : []}
|
||||
|
@ -83,8 +95,11 @@ var Cards = injectIntl(React.createClass({
|
|||
<img src="/svgs/pdf-icon-ui-blue.svg" alt="" className='pdf-icon' />
|
||||
<FormattedMessage id='cards.viewCard' />
|
||||
{(
|
||||
formattedLinks['cards.pongLink'] === englishLinks['cards.pongLink'] &&
|
||||
locale.indexOf('en') === -1
|
||||
this.pdfLocaleMismatch(
|
||||
locale,
|
||||
formattedLinks['cards.pongLink'],
|
||||
englishLinks['cards.pongLink']
|
||||
)
|
||||
) ? [
|
||||
<span> (<FormattedMessage id='cards.english' />)</span>
|
||||
] : []}
|
||||
|
@ -101,8 +116,11 @@ var Cards = injectIntl(React.createClass({
|
|||
<img src="/svgs/pdf-icon-ui-blue.svg" alt="" className='pdf-icon' />
|
||||
<FormattedMessage id='cards.viewCard' />
|
||||
{(
|
||||
formattedLinks['cards.storyLink'] === englishLinks['cards.storyLink'] &&
|
||||
locale.indexOf('en') === -1
|
||||
this.pdfLocaleMismatch(
|
||||
locale,
|
||||
formattedLinks['cards.storyLink'],
|
||||
englishLinks['cards.storyLink']
|
||||
)
|
||||
) ? [
|
||||
<span> (<FormattedMessage id='cards.english' />)</span>
|
||||
] : []}
|
||||
|
@ -117,8 +135,11 @@ var Cards = injectIntl(React.createClass({
|
|||
<img src="/svgs/pdf-icon-ui-blue.svg" alt="" className='pdf-icon' />
|
||||
<FormattedMessage id='cards.viewCard' />
|
||||
{(
|
||||
formattedLinks['cards.danceLink'] === englishLinks['cards.danceLink'] &&
|
||||
locale.indexOf('en') === -1
|
||||
this.pdfLocaleMismatch(
|
||||
locale,
|
||||
formattedLinks['cards.danceLink'],
|
||||
englishLinks['cards.danceLink']
|
||||
)
|
||||
) ? [
|
||||
<span> (<FormattedMessage id='cards.english' />)</span>
|
||||
] : []}
|
||||
|
@ -133,8 +154,11 @@ var Cards = injectIntl(React.createClass({
|
|||
<img src="/svgs/pdf-icon-ui-blue.svg" alt="" className='pdf-icon' />
|
||||
<FormattedMessage id='cards.viewCard' />
|
||||
{(
|
||||
formattedLinks['cards.hideLink'] === englishLinks['cards.hideLink'] &&
|
||||
locale.indexOf('en') === -1
|
||||
this.pdfLocaleMismatch(
|
||||
locale,
|
||||
formattedLinks['cards.hideLink'],
|
||||
englishLinks['cards.hideLink']
|
||||
)
|
||||
) ? [
|
||||
<span> (<FormattedMessage id='cards.english' />)</span>
|
||||
] : []}
|
||||
|
|
Loading…
Reference in a new issue