From 21d8b07bfeedb08e10d8033eb7454d27292bf203 Mon Sep 17 00:00:00 2001 From: DS Boyce <260543580+ds-boyce@users.noreply.github.com> Date: Mon, 23 Mar 2026 09:56:35 -0700 Subject: [PATCH] Use isTranslationSupported from expo-translate-text (#10108) --- src/env/index.ts | 3 --- src/env/index.web.ts | 1 - src/lib/translation/index.tsx | 9 ++++++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/env/index.ts b/src/env/index.ts index d11beafcf4..14abba55a4 100644 --- a/src/env/index.ts +++ b/src/env/index.ts @@ -49,6 +49,3 @@ export const IS_WEB_FIREFOX: boolean = false export const IS_HIGH_DPI: boolean = true // ideally we'd use isLiquidGlassAvailable() from expo-glass-effect but checking iOS version is good enough for now export const IS_LIQUID_GLASS: boolean = iOSMajorVersion >= 26 -// So we can avoid attempting on-device translation when we know it's unsupported. -export const HAS_ON_DEVICE_TRANSLATION: boolean = - (IS_IOS && iOSMajorVersion >= 18) || IS_ANDROID diff --git a/src/env/index.web.ts b/src/env/index.web.ts index ee7462ea84..0a078fdeb0 100644 --- a/src/env/index.web.ts +++ b/src/env/index.web.ts @@ -48,4 +48,3 @@ export const IS_HIGH_DPI: boolean = window.matchMedia( '(min-resolution: 2dppx)', ).matches export const IS_LIQUID_GLASS: boolean = false -export const HAS_ON_DEVICE_TRANSLATION: boolean = false diff --git a/src/lib/translation/index.tsx b/src/lib/translation/index.tsx index a8f1875192..710c9993d1 100644 --- a/src/lib/translation/index.tsx +++ b/src/lib/translation/index.tsx @@ -1,7 +1,10 @@ import {useCallback, useContext, useEffect, useMemo, useState} from 'react' import {LayoutAnimation, Platform} from 'react-native' import {getLocales} from 'expo-localization' -import {onTranslateTask} from '@bsky.app/expo-translate-text' +import { + isTranslationSupported, + onTranslateTask, +} from '@bsky.app/expo-translate-text' import {type TranslationTaskResult} from '@bsky.app/expo-translate-text/build/ExpoTranslateText.types' import {useLingui} from '@lingui/react/macro' import {useFocusEffect} from '@react-navigation/native' @@ -9,7 +12,7 @@ import {useFocusEffect} from '@react-navigation/native' import {useGoogleTranslate} from '#/lib/hooks/useGoogleTranslate' import {logger} from '#/logger' import {useAnalytics} from '#/analytics' -import {HAS_ON_DEVICE_TRANSLATION, IS_ANDROID, IS_IOS} from '#/env' +import {IS_ANDROID, IS_IOS} from '#/env' import {Context} from './context' import { type ContextType, @@ -232,7 +235,7 @@ export function Provider({children}: React.PropsWithChildren) { googleTranslate: shouldForceGoogleTranslate, }) - if (shouldForceGoogleTranslate || !HAS_ON_DEVICE_TRANSLATION) { + if (shouldForceGoogleTranslate || !isTranslationSupported()) { await googleTranslate( text, expectedTargetLanguage,