mirror of
https://github.com/bellingcat/ukraine-timemap.git
synced 2026-06-12 13:28:36 +03:00
cleaner declaration for cover translations
This commit is contained in:
@@ -94,8 +94,22 @@ class SourceOverlay extends React.Component {
|
||||
|
||||
renderIntlContent () {
|
||||
const { langIdx } = this.state
|
||||
const source = langIdx === 0 ? this.props.source : this.props.translations[langIdx - 1]
|
||||
return this.renderContent(source)
|
||||
const { translations, source } = this.props
|
||||
let translated = null
|
||||
if (translations && translations.length && langIdx > 0) {
|
||||
translated = translations[langIdx - 1]
|
||||
}
|
||||
if (translated) {
|
||||
translated = {
|
||||
...translated,
|
||||
poster: source.poster,
|
||||
// NOTE: this is to allow a slightly nicer syntax when using the Media
|
||||
// overlay in cover videos.
|
||||
paths: translated.file ? [translated.file] : translated.paths
|
||||
}
|
||||
}
|
||||
|
||||
return this.renderContent(langIdx === 0 ? source : translated)
|
||||
}
|
||||
|
||||
render () {
|
||||
|
||||
@@ -43,11 +43,18 @@ class TemplateCover extends React.Component {
|
||||
renderFeature () {
|
||||
const { featureVideo } = this.props.cover
|
||||
const { featureLang } = this.state
|
||||
const source = featureLang === 0 ? featureVideo : featureVideo.translations[featureLang - 1]
|
||||
const { translations } = featureVideo
|
||||
const source = featureLang === 0
|
||||
? featureVideo
|
||||
: {
|
||||
...translations[featureLang - 1],
|
||||
poster: featureVideo.poster
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className='banner-trans right-overlay'>
|
||||
{featureVideo.translations && featureVideo.translations.map((trans, idx) => {
|
||||
{translations && translations.map((trans, idx) => {
|
||||
const langIdx = idx + 1 // default lang idx is 0
|
||||
if (featureLang !== langIdx) {
|
||||
return <div onClick={() => this.setState({ featureLang: langIdx })} className='trans-button'>{trans.code}</div>
|
||||
|
||||
Reference in New Issue
Block a user