[Glitch] Translate CW, poll options and media descriptions

Port 69057467cb to glitch-soc

Co-authored-by: Claire <claire.github-309c@sitedethib.com>
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Christian Schmidt
2023-06-01 00:10:21 +02:00
committed by Claire
parent 93c714417f
commit 7e25fd9b0c
15 changed files with 173 additions and 64 deletions

View File

@@ -327,11 +327,11 @@ class StatusContent extends PureComponent {
const hidden = this.props.onExpandedToggle ? !this.props.expanded : this.state.hidden;
const contentLocale = intl.locale.replace(/[_-].*/, '');
const targetLanguages = this.props.languages?.get(status.get('language') || 'und');
const renderTranslate = this.props.onTranslate && this.context.identity.signedIn && ['public', 'unlisted'].includes(status.get('visibility')) && status.get('contentHtml').length > 0 && targetLanguages?.includes(contentLocale);
const renderTranslate = this.props.onTranslate && this.context.identity.signedIn && ['public', 'unlisted'].includes(status.get('visibility')) && status.get('search_index').trim().length > 0 && targetLanguages?.includes(contentLocale);
const content = { __html: status.get('translation') ? status.getIn(['translation', 'content']) : status.get('contentHtml') };
const spoilerContent = { __html: status.get('spoilerHtml') };
const lang = status.get('translation') ? intl.locale : status.get('language');
const content = { __html: status.getIn(['translation', 'contentHtml']) || status.get('contentHtml') };
const spoilerContent = { __html: status.getIn(['translation', 'spoilerHtml']) || status.get('spoilerHtml') };
const language = status.getIn(['translation', 'language']) || status.get('language');
const classNames = classnames('status__content', {
'status__content--with-action': parseClick && !disabled,
'status__content--with-spoiler': status.get('spoiler_text').length > 0,
@@ -396,7 +396,7 @@ class StatusContent extends PureComponent {
<p
style={{ marginBottom: hidden && status.get('mentions').isEmpty() ? '0px' : null }}
>
<span dangerouslySetInnerHTML={spoilerContent} className='translate' lang={lang} />
<span dangerouslySetInnerHTML={spoilerContent} className='translate' lang={language} />
{' '}
<button type='button' className='status__content__spoiler-link' onClick={this.handleSpoilerClick} aria-expanded={!hidden}>
{toggleText}
@@ -414,7 +414,7 @@ class StatusContent extends PureComponent {
className='status__content__text translate'
onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave}
lang={lang}
lang={language}
/>
{!hidden && translateButton}
{media}
@@ -439,7 +439,7 @@ class StatusContent extends PureComponent {
tabIndex={0}
onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave}
lang={lang}
lang={language}
/>
{translateButton}
{media}
@@ -460,7 +460,7 @@ class StatusContent extends PureComponent {
tabIndex={0}
onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave}
lang={lang}
lang={language}
/>
{translateButton}
{media}