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