import { Menu, MenuItem } from '@szhsin/react-menu'; import { useState } from 'preact/hooks'; import { useSnapshot } from 'valtio'; import getTranslateTargetLanguage from '../utils/get-translate-target-language'; import localeMatch from '../utils/locale-match'; import { speak, supportsTTS } from '../utils/speech'; import states from '../utils/states'; import Icon from './icon'; import Menu2 from './menu2'; import TranslationBlock from './translation-block'; export default function MediaAltModal({ alt, lang, onClose }) { const snapStates = useSnapshot(states); const [forceTranslate, setForceTranslate] = useState(false); const targetLanguage = getTranslateTargetLanguage(true); const contentTranslationHideLanguages = snapStates.settings.contentTranslationHideLanguages || []; const differentLanguage = !!lang && lang !== targetLanguage && !localeMatch([lang], [targetLanguage]) && !contentTranslationHideLanguages.find( (l) => lang === l || localeMatch([lang], [l]), ); return (
{!!onClose && ( )}

Media description

} > { setForceTranslate(true); }} > Translate {supportsTTS && ( { speak(alt, lang); }} > Speak )}

{alt}

{(differentLanguage || forceTranslate) && ( )}
); }