···11import {useCallback} from 'react'
22import * as IntentLauncher from 'expo-intent-launcher'
3344+import {useOpenLink} from '#/lib/hooks/useOpenLink'
45import {getTranslatorLink} from '#/locale/helpers'
56import {IS_ANDROID} from '#/env'
66-import {useOpenLink} from './useOpenLink'
7788+/**
99+ * Will always link out to Google Translate. If inline translation is desired,
1010+ * use `useTranslateOnDevice`
1111+ */
812export function useTranslate() {
913 const openLink = useOpenLink()
10141115 return useCallback(
1212- async (text: string, language: string) => {
1313- const translateUrl = getTranslatorLink(text, language)
1616+ async (text: string, targetLangCode: string, sourceLanguage?: string) => {
1717+ const translateUrl = getTranslatorLink(
1818+ text,
1919+ targetLangCode,
2020+ sourceLanguage,
2121+ )
1422 if (IS_ANDROID) {
1523 try {
1616- // use getApplicationIconAsync to determine if the translate app is installed
2424+ // use `getApplicationIconAsync` to determine if the translate app is installed
1725 if (
1826 !(await IntentLauncher.getApplicationIconAsync(
1927 'com.google.android.apps.translate',