diff --git a/CHANGELOG.md b/CHANGELOG.md index a7a1288db..add0b6798 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Posts: fix monospace font in Markdown code blocks. - Modals: fix action buttons overflow - Editing: don't insert edited posts to the top of the feed. +- Posts: let unauthenticated users to translate posts if allowed by backend. ## [3.0.0] - 2022-12-25 diff --git a/app/soapbox/components/translate-button.tsx b/app/soapbox/components/translate-button.tsx index ead0b894a..d6059411c 100644 --- a/app/soapbox/components/translate-button.tsx +++ b/app/soapbox/components/translate-button.tsx @@ -4,10 +4,11 @@ import { FormattedMessage, useIntl } from 'react-intl'; import { translateStatus, undoStatusTranslation } from 'soapbox/actions/statuses'; import { useAppDispatch, useAppSelector, useFeatures, useInstance } from 'soapbox/hooks'; +import { isLocal } from 'soapbox/utils/accounts'; import { Stack } from './ui'; -import type { Status } from 'soapbox/types/entities'; +import type { Account, Status } from 'soapbox/types/entities'; interface ITranslateButton { status: Status, @@ -21,10 +22,13 @@ const TranslateButton: React.FC = ({ status }) => { const me = useAppSelector((state) => state.me); + const allowUnauthenticated = instance.pleroma.getIn(['metadata', 'translation', 'allow_unauthenticated'], false); + const allowRemote = instance.pleroma.getIn(['metadata', 'translation', 'allow_remote'], true); + const sourceLanguages = instance.pleroma.getIn(['metadata', 'translation', 'source_languages']) as ImmutableList; const targetLanguages = instance.pleroma.getIn(['metadata', 'translation', 'target_languages']) as ImmutableList; - const renderTranslate = me && ['public', 'unlisted'].includes(status.visibility) && status.contentHtml.length > 0 && status.language !== null && intl.locale !== status.language; + const renderTranslate = (me || allowUnauthenticated) && (allowRemote || isLocal(status.account as Account)) && ['public', 'unlisted'].includes(status.visibility) && status.contentHtml.length > 0 && status.language !== null && intl.locale !== status.language; const supportsLanguages = (!sourceLanguages || sourceLanguages.includes(status.language!)) && (!targetLanguages || targetLanguages.includes(intl.locale));