this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Auto-translate alt text if short

+15 -6
+10 -1
src/components/media-alt-modal.jsx
··· 1 1 import { Trans, useLingui } from '@lingui/react/macro'; 2 2 import { Menu, MenuItem } from '@szhsin/react-menu'; 3 - import { useState } from 'preact/hooks'; 3 + import { useEffect, useState } from 'preact/hooks'; 4 4 import { useSnapshot } from 'valtio'; 5 5 6 6 import getTranslateTargetLanguage from '../utils/get-translate-target-language'; ··· 11 11 import Icon from './icon'; 12 12 import Menu2 from './menu2'; 13 13 import TranslationBlock from './translation-block'; 14 + 15 + const FORCE_TRANSLATE_LIMIT = 140; 14 16 15 17 export default function MediaAltModal({ alt, lang, onClose }) { 16 18 const { t } = useLingui(); ··· 26 28 !contentTranslationHideLanguages.find( 27 29 (l) => lang === l || localeMatch([lang], [l]), 28 30 ); 31 + 32 + useEffect(() => { 33 + const isShortAlt = alt?.length > 0 && alt?.length <= FORCE_TRANSLATE_LIMIT; 34 + if (differentLanguage && isShortAlt) { 35 + setForceTranslate(true); 36 + } 37 + }, [differentLanguage, alt]); 29 38 30 39 return ( 31 40 <div class="sheet" tabindex="-1">
+5 -5
src/locales/en.po
··· 109 109 #: src/components/account-info.jsx:457 110 110 #: src/components/account-info.jsx:1231 111 111 #: src/components/compose.jsx:2776 112 - #: src/components/media-alt-modal.jsx:46 112 + #: src/components/media-alt-modal.jsx:55 113 113 #: src/components/media-modal.jsx:359 114 114 #: src/components/status.jsx:1818 115 115 #: src/components/status.jsx:1835 ··· 459 459 #: src/components/generic-accounts.jsx:151 460 460 #: src/components/keyboard-shortcuts-help.jsx:43 461 461 #: src/components/list-add-edit.jsx:37 462 - #: src/components/media-alt-modal.jsx:34 462 + #: src/components/media-alt-modal.jsx:43 463 463 #: src/components/media-modal.jsx:323 464 464 #: src/components/notification-service.jsx:157 465 465 #: src/components/report-modal.jsx:75 ··· 1298 1298 msgid "Posts on this list are hidden from Home/Following" 1299 1299 msgstr "Posts on this list are hidden from Home/Following" 1300 1300 1301 - #: src/components/media-alt-modal.jsx:39 1301 + #: src/components/media-alt-modal.jsx:48 1302 1302 #: src/components/media.jsx:51 1303 1303 msgid "Media description" 1304 1304 msgstr "" 1305 1305 1306 - #: src/components/media-alt-modal.jsx:58 1306 + #: src/components/media-alt-modal.jsx:67 1307 1307 #: src/components/status.jsx:1131 1308 1308 #: src/components/status.jsx:1140 1309 1309 #: src/components/translation-block.jsx:237 1310 1310 msgid "Translate" 1311 1311 msgstr "" 1312 1312 1313 - #: src/components/media-alt-modal.jsx:69 1313 + #: src/components/media-alt-modal.jsx:78 1314 1314 #: src/components/status.jsx:1159 1315 1315 msgid "Speak" 1316 1316 msgstr ""