default translate to device language (#1207)
parent
4a59178cd2
commit
55ad56f689
|
@ -79,8 +79,6 @@ export function isPostInLanguage(
|
||||||
return bcp47Match.basicFilter(lang, targetLangs).length > 0
|
return bcp47Match.basicFilter(lang, targetLangs).length > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getTranslatorLink(lang: string, text: string): string {
|
export function getTranslatorLink(text: string): string {
|
||||||
return encodeURI(
|
return encodeURI(`https://translate.google.com/?sl=auto&text=${text}`)
|
||||||
`https://translate.google.com/?sl=auto&tl=${lang}&text=${text}`,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,8 +67,7 @@ export const PostThreadItem = observer(function PostThreadItem({
|
||||||
}, [item.post.uri, item.post.author])
|
}, [item.post.uri, item.post.author])
|
||||||
const repostsTitle = 'Reposts of this post'
|
const repostsTitle = 'Reposts of this post'
|
||||||
|
|
||||||
const primaryLanguage = store.preferences.contentLanguages[0] || 'en'
|
const translatorUrl = getTranslatorLink(record?.text || '')
|
||||||
const translatorUrl = getTranslatorLink(primaryLanguage, record?.text || '')
|
|
||||||
const needsTranslation = useMemo(
|
const needsTranslation = useMemo(
|
||||||
() =>
|
() =>
|
||||||
store.preferences.contentLanguages.length > 0 &&
|
store.preferences.contentLanguages.length > 0 &&
|
||||||
|
|
|
@ -133,8 +133,7 @@ const PostLoaded = observer(
|
||||||
replyAuthorDid = urip.hostname
|
replyAuthorDid = urip.hostname
|
||||||
}
|
}
|
||||||
|
|
||||||
const primaryLanguage = store.preferences.contentLanguages[0] || 'en'
|
const translatorUrl = getTranslatorLink(record?.text || '')
|
||||||
const translatorUrl = getTranslatorLink(primaryLanguage, record?.text || '')
|
|
||||||
const needsTranslation = useMemo(
|
const needsTranslation = useMemo(
|
||||||
() =>
|
() =>
|
||||||
store.preferences.contentLanguages.length > 0 &&
|
store.preferences.contentLanguages.length > 0 &&
|
||||||
|
|
|
@ -60,8 +60,7 @@ export const FeedItem = observer(function ({
|
||||||
const urip = new AtUri(record.reply.parent?.uri || record.reply.root.uri)
|
const urip = new AtUri(record.reply.parent?.uri || record.reply.root.uri)
|
||||||
return urip.hostname
|
return urip.hostname
|
||||||
}, [record?.reply])
|
}, [record?.reply])
|
||||||
const primaryLanguage = store.preferences.contentLanguages[0] || 'en'
|
const translatorUrl = getTranslatorLink(record?.text || '')
|
||||||
const translatorUrl = getTranslatorLink(primaryLanguage, record?.text || '')
|
|
||||||
const needsTranslation = useMemo(
|
const needsTranslation = useMemo(
|
||||||
() =>
|
() =>
|
||||||
store.preferences.contentLanguages.length > 0 &&
|
store.preferences.contentLanguages.length > 0 &&
|
||||||
|
|
Loading…
Reference in New Issue