···1import {useCallback} from 'react'
2import * as IntentLauncher from 'expo-intent-launcher'
304import {getTranslatorLink} from '#/locale/helpers'
5import {IS_ANDROID} from '#/env'
6-import {useOpenLink} from './useOpenLink'
700008export function useTranslate() {
9 const openLink = useOpenLink()
1011 return useCallback(
12- async (text: string, language: string) => {
13- const translateUrl = getTranslatorLink(text, language)
000014 if (IS_ANDROID) {
15 try {
16- // use getApplicationIconAsync to determine if the translate app is installed
17 if (
18 !(await IntentLauncher.getApplicationIconAsync(
19 'com.google.android.apps.translate',
···1import {useCallback} from 'react'
2import * as IntentLauncher from 'expo-intent-launcher'
34+import {useOpenLink} from '#/lib/hooks/useOpenLink'
5import {getTranslatorLink} from '#/locale/helpers'
6import {IS_ANDROID} from '#/env'
078+/**
9+ * Will always link out to Google Translate. If inline translation is desired,
10+ * use `useTranslateOnDevice`
11+ */
12export function useTranslate() {
13 const openLink = useOpenLink()
1415 return useCallback(
16+ async (text: string, targetLangCode: string, sourceLanguage?: string) => {
17+ const translateUrl = getTranslatorLink(
18+ text,
19+ targetLangCode,
20+ sourceLanguage,
21+ )
22 if (IS_ANDROID) {
23 try {
24+ // use `getApplicationIconAsync` to determine if the translate app is installed
25 if (
26 !(await IntentLauncher.getApplicationIconAsync(
27 'com.google.android.apps.translate',
···4import {useLingui} from '@lingui/react'
5import type React from 'react'
607import {useKawaiiMode} from '#/state/preferences/kawaii'
8import {useSession} from '#/state/session'
9import {useShellLayout} from '#/state/shell/shell-layout'
···53 </View>
54 <Link
55 to="/feeds"
56- hitSlop={10}
57 label={_(msg`View your feeds and explore more`)}
58 size="small"
59 variant="ghost"
···4import {useLingui} from '@lingui/react'
5import type React from 'react'
67+import {HITSLOP_10} from '#/lib/constants'
8import {useKawaiiMode} from '#/state/preferences/kawaii'
9import {useSession} from '#/state/session'
10import {useShellLayout} from '#/state/shell/shell-layout'
···54 </View>
55 <Link
56 to="/feeds"
57+ hitSlop={HITSLOP_10}
58 label={_(msg`View your feeds and explore more`)}
59 size="small"
60 variant="ghost"