Add lang
attribute to media and poll options (#23891)
This commit is contained in:
parent
730bb3e211
commit
d3eefead30
16 changed files with 79 additions and 24 deletions
|
@ -7,15 +7,17 @@ import ImmutablePureComponent from 'react-immutable-pure-component';
|
|||
import Footer from 'mastodon/features/picture_in_picture/components/footer';
|
||||
|
||||
const mapStateToProps = (state, { statusId }) => ({
|
||||
language: state.getIn(['statuses', statusId, 'language']),
|
||||
accountStaticAvatar: state.getIn(['accounts', state.getIn(['statuses', statusId, 'account']), 'avatar_static']),
|
||||
});
|
||||
|
||||
export default @connect(mapStateToProps)
|
||||
export default @connect(mapStateToProps, null, null, { forwardRef: true })
|
||||
class AudioModal extends ImmutablePureComponent {
|
||||
|
||||
static propTypes = {
|
||||
media: ImmutablePropTypes.map.isRequired,
|
||||
statusId: PropTypes.string.isRequired,
|
||||
language: PropTypes.string,
|
||||
accountStaticAvatar: PropTypes.string.isRequired,
|
||||
options: PropTypes.shape({
|
||||
autoPlay: PropTypes.bool,
|
||||
|
@ -25,7 +27,7 @@ class AudioModal extends ImmutablePureComponent {
|
|||
};
|
||||
|
||||
render () {
|
||||
const { media, accountStaticAvatar, statusId, onClose } = this.props;
|
||||
const { media, language, accountStaticAvatar, statusId, onClose } = this.props;
|
||||
const options = this.props.options || {};
|
||||
|
||||
return (
|
||||
|
@ -34,6 +36,7 @@ class AudioModal extends ImmutablePureComponent {
|
|||
<Audio
|
||||
src={media.get('url')}
|
||||
alt={media.get('description')}
|
||||
lang={language}
|
||||
duration={media.getIn(['meta', 'original', 'duration'], 0)}
|
||||
height={150}
|
||||
poster={media.get('preview_url') || accountStaticAvatar}
|
||||
|
|
|
@ -12,6 +12,7 @@ import RelativeTimestamp from 'mastodon/components/relative_timestamp';
|
|||
import MediaAttachments from 'mastodon/components/media_attachments';
|
||||
|
||||
const mapStateToProps = (state, { statusId }) => ({
|
||||
language: state.getIn(['statuses', statusId, 'language']),
|
||||
versions: state.getIn(['history', statusId, 'items']),
|
||||
});
|
||||
|
||||
|
@ -30,11 +31,12 @@ class CompareHistoryModal extends React.PureComponent {
|
|||
onClose: PropTypes.func.isRequired,
|
||||
index: PropTypes.number.isRequired,
|
||||
statusId: PropTypes.string.isRequired,
|
||||
language: PropTypes.string.isRequired,
|
||||
versions: ImmutablePropTypes.list.isRequired,
|
||||
};
|
||||
|
||||
render () {
|
||||
const { index, versions, onClose } = this.props;
|
||||
const { index, versions, language, onClose } = this.props;
|
||||
const currentVersion = versions.get(index);
|
||||
|
||||
const emojiMap = currentVersion.get('emojis').reduce((obj, emoji) => {
|
||||
|
@ -65,12 +67,12 @@ class CompareHistoryModal extends React.PureComponent {
|
|||
<div className='status__content'>
|
||||
{currentVersion.get('spoiler_text').length > 0 && (
|
||||
<React.Fragment>
|
||||
<div className='translate' dangerouslySetInnerHTML={spoilerContent} />
|
||||
<div className='translate' dangerouslySetInnerHTML={spoilerContent} lang={language} />
|
||||
<hr />
|
||||
</React.Fragment>
|
||||
)}
|
||||
|
||||
<div className='status__content__text status__content__text--visible translate' dangerouslySetInnerHTML={content} />
|
||||
<div className='status__content__text status__content__text--visible translate' dangerouslySetInnerHTML={content} lang={language} />
|
||||
|
||||
{!!currentVersion.get('poll') && (
|
||||
<div className='poll'>
|
||||
|
@ -82,6 +84,7 @@ class CompareHistoryModal extends React.PureComponent {
|
|||
<span
|
||||
className='poll__option__text translate'
|
||||
dangerouslySetInnerHTML={{ __html: emojify(escapeTextContentForBrowser(option.get('title')), emojiMap) }}
|
||||
lang={language}
|
||||
/>
|
||||
</li>
|
||||
))}
|
||||
|
@ -89,7 +92,7 @@ class CompareHistoryModal extends React.PureComponent {
|
|||
</div>
|
||||
)}
|
||||
|
||||
<MediaAttachments status={currentVersion} />
|
||||
<MediaAttachments status={currentVersion} lang={language} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -8,6 +8,7 @@ export default class ImageLoader extends PureComponent {
|
|||
|
||||
static propTypes = {
|
||||
alt: PropTypes.string,
|
||||
lang: PropTypes.string,
|
||||
src: PropTypes.string.isRequired,
|
||||
previewSrc: PropTypes.string,
|
||||
width: PropTypes.number,
|
||||
|
@ -18,6 +19,7 @@ export default class ImageLoader extends PureComponent {
|
|||
|
||||
static defaultProps = {
|
||||
alt: '',
|
||||
lang: '',
|
||||
width: null,
|
||||
height: null,
|
||||
};
|
||||
|
@ -129,7 +131,7 @@ export default class ImageLoader extends PureComponent {
|
|||
};
|
||||
|
||||
render () {
|
||||
const { alt, src, width, height, onClick } = this.props;
|
||||
const { alt, lang, src, width, height, onClick } = this.props;
|
||||
const { loading } = this.state;
|
||||
|
||||
const className = classNames('image-loader', {
|
||||
|
@ -154,6 +156,7 @@ export default class ImageLoader extends PureComponent {
|
|||
) : (
|
||||
<ZoomableImage
|
||||
alt={alt}
|
||||
lang={lang}
|
||||
src={src}
|
||||
onClick={onClick}
|
||||
width={width}
|
||||
|
|
|
@ -3,6 +3,7 @@ import ReactSwipeableViews from 'react-swipeable-views';
|
|||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import PropTypes from 'prop-types';
|
||||
import Video from 'mastodon/features/video';
|
||||
import { connect } from 'react-redux';
|
||||
import classNames from 'classnames';
|
||||
import { defineMessages, injectIntl } from 'react-intl';
|
||||
import IconButton from 'mastodon/components/icon_button';
|
||||
|
@ -20,7 +21,12 @@ const messages = defineMessages({
|
|||
next: { id: 'lightbox.next', defaultMessage: 'Next' },
|
||||
});
|
||||
|
||||
export default @injectIntl
|
||||
const mapStateToProps = (state, { statusId }) => ({
|
||||
language: state.getIn(['statuses', statusId, 'language']),
|
||||
});
|
||||
|
||||
export default @connect(mapStateToProps, null, null, { forwardRef: true })
|
||||
@injectIntl
|
||||
class MediaModal extends ImmutablePureComponent {
|
||||
|
||||
static propTypes = {
|
||||
|
@ -129,7 +135,7 @@ class MediaModal extends ImmutablePureComponent {
|
|||
};
|
||||
|
||||
render () {
|
||||
const { media, statusId, intl, onClose } = this.props;
|
||||
const { media, language, statusId, intl, onClose } = this.props;
|
||||
const { navigationHidden } = this.state;
|
||||
|
||||
const index = this.getIndex();
|
||||
|
@ -149,6 +155,7 @@ class MediaModal extends ImmutablePureComponent {
|
|||
width={width}
|
||||
height={height}
|
||||
alt={image.get('description')}
|
||||
lang={language}
|
||||
key={image.get('url')}
|
||||
onClick={this.toggleNavigation}
|
||||
zoomButtonHidden={this.state.zoomButtonHidden}
|
||||
|
@ -171,6 +178,7 @@ class MediaModal extends ImmutablePureComponent {
|
|||
onCloseVideo={onClose}
|
||||
detailed
|
||||
alt={image.get('description')}
|
||||
lang={language}
|
||||
key={image.get('url')}
|
||||
/>
|
||||
);
|
||||
|
@ -182,6 +190,7 @@ class MediaModal extends ImmutablePureComponent {
|
|||
height={height}
|
||||
key={image.get('preview_url')}
|
||||
alt={image.get('description')}
|
||||
lang={language}
|
||||
onClick={this.toggleNavigation}
|
||||
/>
|
||||
);
|
||||
|
|
|
@ -2,15 +2,22 @@ import React from 'react';
|
|||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import PropTypes from 'prop-types';
|
||||
import Video from 'mastodon/features/video';
|
||||
import { connect } from 'react-redux';
|
||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||
import Footer from 'mastodon/features/picture_in_picture/components/footer';
|
||||
import { getAverageFromBlurhash } from 'mastodon/blurhash';
|
||||
|
||||
export default class VideoModal extends ImmutablePureComponent {
|
||||
const mapStateToProps = (state, { statusId }) => ({
|
||||
language: state.getIn(['statuses', statusId, 'language']),
|
||||
});
|
||||
|
||||
export default @connect(mapStateToProps, null, null, { forwardRef: true })
|
||||
class VideoModal extends ImmutablePureComponent {
|
||||
|
||||
static propTypes = {
|
||||
media: ImmutablePropTypes.map.isRequired,
|
||||
statusId: PropTypes.string,
|
||||
language: PropTypes.string,
|
||||
options: PropTypes.shape({
|
||||
startTime: PropTypes.number,
|
||||
autoPlay: PropTypes.bool,
|
||||
|
@ -31,7 +38,7 @@ export default class VideoModal extends ImmutablePureComponent {
|
|||
}
|
||||
|
||||
render () {
|
||||
const { media, statusId, onClose } = this.props;
|
||||
const { media, statusId, language, onClose } = this.props;
|
||||
const options = this.props.options || {};
|
||||
|
||||
return (
|
||||
|
@ -49,6 +56,7 @@ export default class VideoModal extends ImmutablePureComponent {
|
|||
autoFocus
|
||||
detailed
|
||||
alt={media.get('description')}
|
||||
lang={language}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -96,6 +96,7 @@ class ZoomableImage extends React.PureComponent {
|
|||
|
||||
static propTypes = {
|
||||
alt: PropTypes.string,
|
||||
lang: PropTypes.string,
|
||||
src: PropTypes.string.isRequired,
|
||||
width: PropTypes.number,
|
||||
height: PropTypes.number,
|
||||
|
@ -106,6 +107,7 @@ class ZoomableImage extends React.PureComponent {
|
|||
|
||||
static defaultProps = {
|
||||
alt: '',
|
||||
lang: '',
|
||||
width: null,
|
||||
height: null,
|
||||
};
|
||||
|
@ -403,7 +405,7 @@ class ZoomableImage extends React.PureComponent {
|
|||
};
|
||||
|
||||
render () {
|
||||
const { alt, src, width, height, intl } = this.props;
|
||||
const { alt, lang, src, width, height, intl } = this.props;
|
||||
const { scale, lockTranslate } = this.state;
|
||||
const overflow = scale === MIN_SCALE ? 'hidden' : 'scroll';
|
||||
const zoomButtonShouldHide = this.state.navigationHidden || this.props.zoomButtonHidden || this.state.zoomMatrix.rate <= MIN_SCALE ? 'media-modal__zoom-button--hidden' : '';
|
||||
|
@ -431,6 +433,7 @@ class ZoomableImage extends React.PureComponent {
|
|||
ref={this.setImageRef}
|
||||
alt={alt}
|
||||
title={alt}
|
||||
lang={lang}
|
||||
src={src}
|
||||
width={width}
|
||||
height={height}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue