translate to primary language rather than just english (#814)

zio/stable
Samuel Newman 2023-06-01 16:50:18 +01:00 committed by GitHub
parent 1fc694d488
commit 88212eb065
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 6 deletions

View File

@ -97,15 +97,17 @@ export const PostThreadItem = observer(function PostThreadItem({
Toast.show('Copied to clipboard')
}, [record])
const primaryLanguage = store.preferences.contentLanguages[0] || 'en'
const onOpenTranslate = React.useCallback(() => {
Linking.openURL(
encodeURI(
`https://translate.google.com/?sl=auto&tl=en&text=${
`https://translate.google.com/?sl=auto&tl=${primaryLanguage}&text=${
record?.text || ''
}`,
),
)
}, [record])
}, [record, primaryLanguage])
const onToggleThreadMute = React.useCallback(async () => {
try {

View File

@ -167,15 +167,17 @@ const PostLoaded = observer(
Toast.show('Copied to clipboard')
}, [record])
const primaryLanguage = store.preferences.contentLanguages[0] || 'en'
const onOpenTranslate = React.useCallback(() => {
Linking.openURL(
encodeURI(
`https://translate.google.com/?sl=auto&tl=en&text=${
`https://translate.google.com/?sl=auto&tl=${primaryLanguage}&text=${
record?.text || ''
}`,
),
)
}, [record])
}, [record, primaryLanguage])
const onToggleThreadMute = React.useCallback(async () => {
try {

View File

@ -97,15 +97,17 @@ export const FeedItem = observer(function ({
Toast.show('Copied to clipboard')
}, [record])
const primaryLanguage = store.preferences.contentLanguages[0] || 'en'
const onOpenTranslate = React.useCallback(() => {
Linking.openURL(
encodeURI(
`https://translate.google.com/?sl=auto&tl=en&text=${
`https://translate.google.com/?sl=auto&tl=${primaryLanguage}&text=${
record?.text || ''
}`,
),
)
}, [record])
}, [record, primaryLanguage])
const onToggleThreadMute = React.useCallback(async () => {
track('FeedItem:ThreadMute')