From 87ce6db1cdbed0e5f0f353ae14451be6c2b254f0 Mon Sep 17 00:00:00 2001 From: Matthew Taylor Date: Tue, 24 May 2016 14:27:16 -0400 Subject: [PATCH] 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. --- src/views/cards/cards.jsx | 48 +++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/src/views/cards/cards.jsx b/src/views/cards/cards.jsx index 70de3cc63..d9d59a497 100644 --- a/src/views/cards/cards.jsx +++ b/src/views/cards/cards.jsx @@ -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({ {( - formattedLinks['cards.starterLink'] === englishLinks['cards.starterLink'] && - locale.indexOf('en') === -1 + this.pdfLocaleMismatch( + locale, + formattedLinks['cards.starterLink'], + englishLinks['cards.starterLink'] + ) ) ? [ ] : []} @@ -67,8 +76,11 @@ var Cards = injectIntl(React.createClass({ {( - formattedLinks['cards.nameLink'] === englishLinks['cards.nameLink'] && - locale.indexOf('en') === -1 + this.pdfLocaleMismatch( + locale, + formattedLinks['cards.nameLink'], + englishLinks['cards.nameLink'] + ) ) ? [ () ] : []} @@ -83,8 +95,11 @@ var Cards = injectIntl(React.createClass({ {( - formattedLinks['cards.pongLink'] === englishLinks['cards.pongLink'] && - locale.indexOf('en') === -1 + this.pdfLocaleMismatch( + locale, + formattedLinks['cards.pongLink'], + englishLinks['cards.pongLink'] + ) ) ? [ () ] : []} @@ -101,8 +116,11 @@ var Cards = injectIntl(React.createClass({ {( - formattedLinks['cards.storyLink'] === englishLinks['cards.storyLink'] && - locale.indexOf('en') === -1 + this.pdfLocaleMismatch( + locale, + formattedLinks['cards.storyLink'], + englishLinks['cards.storyLink'] + ) ) ? [ () ] : []} @@ -117,8 +135,11 @@ var Cards = injectIntl(React.createClass({ {( - formattedLinks['cards.danceLink'] === englishLinks['cards.danceLink'] && - locale.indexOf('en') === -1 + this.pdfLocaleMismatch( + locale, + formattedLinks['cards.danceLink'], + englishLinks['cards.danceLink'] + ) ) ? [ () ] : []} @@ -133,8 +154,11 @@ var Cards = injectIntl(React.createClass({ {( - formattedLinks['cards.hideLink'] === englishLinks['cards.hideLink'] && - locale.indexOf('en') === -1 + this.pdfLocaleMismatch( + locale, + formattedLinks['cards.hideLink'], + englishLinks['cards.hideLink'] + ) ) ? [ () ] : []}