Fix translations on Android using PROCESS_TEXT intent (#8486)
* use intents to translate text on android * clean up config plugins * restore day night plugin just to be safe * leave a comment for why we can't open translate directly * add todo * fix lockfile lint
This commit is contained in:
@@ -5,9 +5,8 @@ import {type ChatBskyConvoDefs, RichText} from '@atproto/api'
|
||||
import {msg} from '@lingui/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
|
||||
import {useOpenLink} from '#/lib/hooks/useOpenLink'
|
||||
import {useTranslate} from '#/lib/hooks/useTranslate'
|
||||
import {richTextToString} from '#/lib/strings/rich-text-helpers'
|
||||
import {getTranslatorLink} from '#/locale/helpers'
|
||||
import {logger} from '#/logger'
|
||||
import {isNative} from '#/platform/detection'
|
||||
import {useConvoActive} from '#/state/messages/convo'
|
||||
@@ -39,7 +38,7 @@ export let MessageContextMenu = ({
|
||||
const deleteControl = usePromptControl()
|
||||
const reportControl = usePromptControl()
|
||||
const langPrefs = useLanguagePrefs()
|
||||
const openLink = useOpenLink()
|
||||
const translate = useTranslate()
|
||||
|
||||
const isFromSelf = message.sender?.did === currentAccount?.did
|
||||
|
||||
@@ -57,11 +56,7 @@ export let MessageContextMenu = ({
|
||||
}, [_, message.text, message.facets])
|
||||
|
||||
const onPressTranslateMessage = useCallback(() => {
|
||||
const translatorUrl = getTranslatorLink(
|
||||
message.text,
|
||||
langPrefs.primaryLanguage,
|
||||
)
|
||||
openLink(translatorUrl, true)
|
||||
translate(message.text, langPrefs.primaryLanguage)
|
||||
|
||||
logger.metric(
|
||||
'translate',
|
||||
@@ -72,7 +67,7 @@ export let MessageContextMenu = ({
|
||||
},
|
||||
{statsig: false},
|
||||
)
|
||||
}, [langPrefs.primaryLanguage, message.text, openLink])
|
||||
}, [langPrefs.primaryLanguage, message.text, translate])
|
||||
|
||||
const onDelete = useCallback(() => {
|
||||
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut)
|
||||
|
||||
Reference in New Issue
Block a user