Log languages a post is tagged with after translating (#10014)
Co-authored-by: Eric Bailey <git@esb.lol>
This commit is contained in:
@@ -9,6 +9,7 @@ import {useTranslate} from '#/lib/translation'
|
||||
import {type TranslationFunction} from '#/lib/translation'
|
||||
import {
|
||||
codeToLanguageName,
|
||||
getPostLanguageTags,
|
||||
isPostInLanguage,
|
||||
languageName,
|
||||
} from '#/locale/helpers'
|
||||
@@ -42,6 +43,7 @@ export function TranslatedPost({
|
||||
const langPrefs = useLanguagePrefs()
|
||||
const {clearTranslation, translate, translationState} = useTranslate({
|
||||
key: post.uri,
|
||||
postLangCodes: getPostLanguageTags(post),
|
||||
})
|
||||
|
||||
const needsTranslation = useMemo(() => {
|
||||
@@ -122,6 +124,7 @@ function TranslationLink({
|
||||
})
|
||||
|
||||
ax.metric('translate', {
|
||||
os: Platform.OS,
|
||||
sourceLanguages: [], // todo: get from post maybe?
|
||||
targetLanguage: primaryLanguage,
|
||||
textLength: postText.length,
|
||||
@@ -405,6 +408,7 @@ function TranslationLanguageSelect({
|
||||
text: postText,
|
||||
targetLangCode: langPrefs.primaryLanguage,
|
||||
sourceLangCode,
|
||||
sourceSelection: 'manual',
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import {
|
||||
import {richTextToString} from '#/lib/strings/rich-text-helpers'
|
||||
import {toShareUrl} from '#/lib/strings/url-helpers'
|
||||
import {useTranslate} from '#/lib/translation'
|
||||
import {getPostLanguageTags} from '#/locale/helpers'
|
||||
import {logger} from '#/logger'
|
||||
import {type Shadow} from '#/state/cache/post-shadow'
|
||||
import {useProfileShadow} from '#/state/cache/profile-shadow'
|
||||
@@ -137,6 +138,7 @@ let PostMenuItems = ({
|
||||
const openLink = useOpenLink()
|
||||
const {clearTranslation, translate, translationState} = useTranslate({
|
||||
key: post.uri,
|
||||
postLangCodes: getPostLanguageTags(post),
|
||||
forceGoogleTranslate,
|
||||
})
|
||||
const navigation = useNavigation<NavigationProp>()
|
||||
@@ -287,6 +289,7 @@ let PostMenuItems = ({
|
||||
)
|
||||
) {
|
||||
ax.metric('translate', {
|
||||
os: Platform.OS,
|
||||
sourceLanguages: post.record.langs ?? [],
|
||||
targetLanguage: langPrefs.primaryLanguage,
|
||||
textLength: post.record.text.length,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {memo, useCallback} from 'react'
|
||||
import {LayoutAnimation} from 'react-native'
|
||||
import {LayoutAnimation, Platform} from 'react-native'
|
||||
import * as Clipboard from 'expo-clipboard'
|
||||
import {type ChatBskyConvoDefs, RichText} from '@atproto/api'
|
||||
import {msg} from '@lingui/core/macro'
|
||||
@@ -67,6 +67,7 @@ export let MessageContextMenu = ({
|
||||
void translate(message.text, langPrefs.primaryLanguage)
|
||||
|
||||
ax.metric('translate', {
|
||||
os: Platform.OS,
|
||||
sourceLanguages: [],
|
||||
targetLanguage: langPrefs.primaryLanguage,
|
||||
textLength: message.text.length,
|
||||
|
||||
Reference in New Issue
Block a user