Rename useTranslateOnDevice

This commit is contained in:
DS Boyce
2026-03-03 11:20:20 -08:00
parent a9eba81c4a
commit b7ab03bf18
4 changed files with 10 additions and 10 deletions
+3 -3
View File
@@ -3,7 +3,7 @@ import {Platform, View} from 'react-native'
import {Trans, useLingui} from '@lingui/react/macro'
import {HITSLOP_30} from '#/lib/constants'
import {useTranslateOnDevice, useTranslationKey} from '#/lib/translation'
import {useTranslate, useTranslationKey} from '#/lib/translation'
import {codeToLanguageName, languageName} from '#/locale/helpers'
import {LANGUAGES} from '#/locale/languages'
import {useLanguagePrefs} from '#/state/preferences'
@@ -21,7 +21,7 @@ export function TranslatedPost({
translationKey: string
postText: string
}) {
const {translationState} = useTranslateOnDevice()
const {translationState} = useTranslate()
// Register this component as using this translation key with focus-based cleanup
useTranslationKey(translationKey)
@@ -119,7 +119,7 @@ function TranslationLanguageSelect({
const ax = useAnalytics()
const {t: l} = useLingui()
const langPrefs = useLanguagePrefs()
const {translate} = useTranslateOnDevice()
const {translate} = useTranslate()
const items = useMemo(
() =>
@@ -27,7 +27,7 @@ import {
} from '#/lib/routes/types'
import {richTextToString} from '#/lib/strings/rich-text-helpers'
import {toShareUrl} from '#/lib/strings/url-helpers'
import {useTranslateOnDevice} from '#/lib/translation'
import {useTranslate} from '#/lib/translation'
import {logger} from '#/logger'
import {type Shadow} from '#/state/cache/post-shadow'
import {useProfileShadow} from '#/state/cache/profile-shadow'
@@ -135,7 +135,7 @@ let PostMenuItems = ({
const {hidePost} = useHiddenPostsApi()
const feedFeedback = useFeedFeedbackContext()
const openLink = useOpenLink()
const {clearTranslation, translate, translationState} = useTranslateOnDevice()
const {clearTranslation, translate, translationState} = useTranslate()
const navigation = useNavigation<NavigationProp>()
const {mutedWordsDialogControl} = useGlobalDialogsControlContext()
const blockPromptControl = useDialogControl()
+3 -3
View File
@@ -78,11 +78,11 @@ async function attemptTranslation(
*
* Web uses index.web.ts which always opens Google Translate.
*/
export function useTranslateOnDevice() {
export function useTranslate() {
const context = useContext(Context)
if (!context) {
throw new Error(
'useTranslateOnDevice must be used within a TranslateOnDeviceProvider',
'useTranslate must be used within a TranslateOnDeviceProvider',
)
}
return context
@@ -95,7 +95,7 @@ export function useTranslateOnDevice() {
* loses focus.
*/
export function useTranslationKey(key: string) {
const {acquireTranslation} = useTranslateOnDevice()
const {acquireTranslation} = useTranslate()
useFocusEffect(
useCallback(() => {
+2 -2
View File
@@ -17,11 +17,11 @@ export function useTranslationKey(_key: string) {}
/**
* Web always opens Google Translate.
*/
export function useTranslateOnDevice() {
export function useTranslate() {
const context = useContext(Context)
if (!context) {
throw new Error(
'useTranslateOnDevice must be used within a TranslateOnDeviceProvider',
'useTranslate must be used within a TranslateOnDeviceProvider',
)
}
return context