Merge pull request #330 from tooot-app/main

Another test
This commit is contained in:
xmflsct 2022-06-10 20:53:31 +02:00 committed by GitHub
commit 4d003de83f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 97 additions and 49 deletions

View File

@ -1,6 +1,5 @@
import Button from '@components/Button' import Button from '@components/Button'
import Icon from '@components/Icon' import Icon from '@components/Icon'
import { useAccessibility } from '@utils/accessibility/AccessibilityManager'
import { useAppsQuery } from '@utils/queryHooks/apps' import { useAppsQuery } from '@utils/queryHooks/apps'
import { useInstanceQuery } from '@utils/queryHooks/instance' import { useInstanceQuery } from '@utils/queryHooks/instance'
import { getInstances } from '@utils/slices/instancesSlice' import { getInstances } from '@utils/slices/instancesSlice'
@ -9,7 +8,7 @@ import { useTheme } from '@utils/styles/ThemeManager'
import * as WebBrowser from 'expo-web-browser' import * as WebBrowser from 'expo-web-browser'
import { debounce } from 'lodash' import { debounce } from 'lodash'
import React, { RefObject, useCallback, useMemo, useState } from 'react' import React, { RefObject, useCallback, useMemo, useState } from 'react'
import { useTranslation } from 'react-i18next' import { Trans, useTranslation } from 'react-i18next'
import { import {
Alert, Alert,
Image, Image,
@ -39,7 +38,6 @@ const ComponentInstance: React.FC<Props> = ({
}) => { }) => {
const { t } = useTranslation('componentInstance') const { t } = useTranslation('componentInstance')
const { colors, mode } = useTheme() const { colors, mode } = useTheme()
const { screenReaderEnabled } = useAccessibility()
const instances = useSelector(getInstances, () => true) const instances = useSelector(getInstances, () => true)
const [domain, setDomain] = useState<string>() const [domain, setDomain] = useState<string>()
@ -247,7 +245,7 @@ const ComponentInstance: React.FC<Props> = ({
style={{ style={{
flexDirection: 'row', flexDirection: 'row',
marginHorizontal: StyleConstants.Spacing.Global.PagePadding, marginHorizontal: StyleConstants.Spacing.Global.PagePadding,
marginVertical: StyleConstants.Spacing.M marginTop: StyleConstants.Spacing.M
}} }}
> >
<Icon <Icon
@ -265,29 +263,59 @@ const ComponentInstance: React.FC<Props> = ({
<CustomText <CustomText
fontStyle='S' fontStyle='S'
style={{ flex: 1, color: colors.secondary }} style={{ flex: 1, color: colors.secondary }}
accessibilityRole='link'
onPress={() => {
if (screenReaderEnabled) {
analytics('view_privacy')
WebBrowser.openBrowserAsync(
'https://tooot.app/privacy-policy'
)
}
}}
> >
{t('server.disclaimer.base')} {t('server.disclaimer.base')}
<CustomText </CustomText>
accessible </View>
style={{ color: colors.blue }} <View
onPress={() => { style={{
analytics('view_privacy') flexDirection: 'row',
WebBrowser.openBrowserAsync( marginHorizontal: StyleConstants.Spacing.Global.PagePadding,
'https://tooot.app/privacy-policy' marginBottom: StyleConstants.Spacing.M
) }}
}} >
> <Icon
{t('server.disclaimer.privacy')} name='CheckSquare'
</CustomText> size={StyleConstants.Font.Size.S}
color={colors.secondary}
style={{
marginTop:
(StyleConstants.Font.LineHeight.S -
StyleConstants.Font.Size.S) /
2,
marginRight: StyleConstants.Spacing.XS
}}
/>
<CustomText
fontStyle='S'
style={{ flex: 1, color: colors.secondary }}
accessibilityRole='link'
>
<Trans
i18nKey='componentInstance:server.terms.base'
components={[
<CustomText
accessible
style={{ color: colors.blue }}
onPress={() => {
analytics('view_privacy')
WebBrowser.openBrowserAsync(
'https://tooot.app/privacy-policy'
)
}}
/>,
<CustomText
accessible
style={{ color: colors.blue }}
onPress={() => {
analytics('view_tos')
WebBrowser.openBrowserAsync(
'https://tooot.app/terms-of-service'
)
}}
/>
]}
/>
</CustomText> </CustomText>
</View> </View>
</View> </View>

View File

@ -30,35 +30,41 @@ const TimelineTranslate = React.memo(
const { t } = useTranslation('componentTimeline') const { t } = useTranslation('componentTimeline')
const { colors } = useTheme() const { colors } = useTheme()
let text = status.spoiler_text const text = status.spoiler_text
? [status.spoiler_text, status.content] ? [status.spoiler_text, status.content]
: [status.content] : [status.content]
for (const i in text) { for (const i in text) {
for (const emoji of status.emojis) { for (const emoji of status.emojis) {
text[i] = text[i].replaceAll(`:${emoji.shortcode}:`, '') text[i] = text[i].replaceAll(`:${emoji.shortcode}:`, ' ')
} }
text[i] = text[i]
.replace(/(<([^>]+)>)/gi, ' ')
.replace(/@.*? /gi, ' ')
.replace(/#.*? /gi, ' ')
.replace(/http(s):\/\/.*? /gi, ' ')
} }
const [detectedLanguage, setDetectedLanguage] = useState<string>('') const [detectedLanguage, setDetectedLanguage] = useState<string>('')
useEffect(() => { useEffect(() => {
const detect = async () => { const detect = async () => {
const result = await detectLanguage(text.join(`\n`)) const result = await detectLanguage(text.join(`\n\n`))
setDetectedLanguage(result.detected.slice(0, 2)) setDetectedLanguage(result.detected.slice(0, 2))
} }
detect() detect()
}, []) }, [])
const settingsLanguage = useSelector(getSettingsLanguage) const settingsLanguage = useSelector(getSettingsLanguage)
const targetLanguage = settingsLanguage || Localization.locale || 'en'
const [enabled, setEnabled] = useState(false) const [enabled, setEnabled] = useState(false)
const { refetch, data, isLoading, isSuccess, isError } = useTranslateQuery({ const { refetch, data, isLoading, isSuccess, isError } = useTranslateQuery({
source: detectedLanguage, source: detectedLanguage,
target: Localization.locale || settingsLanguage || 'en', target: targetLanguage,
text, text,
options: { enabled } options: { enabled }
}) })
console.log('detectedLanguage', detectedLanguage)
if (!detectedLanguage) { if (!detectedLanguage) {
return null return null
} }
@ -118,9 +124,7 @@ const TimelineTranslate = React.memo(
</CustomText> </CustomText>
<CustomText> <CustomText>
{__DEV__ {__DEV__
? ` Source: ${detectedLanguage}; Target: ${ ? ` Source: ${detectedLanguage}; Target: ${targetLanguage}`
Localization.locale || settingsLanguage || 'en'
}`
: undefined} : undefined}
</CustomText> </CustomText>
{isLoading ? ( {isLoading ? (

View File

@ -11,8 +11,10 @@
"domains": "Domains" "domains": "Domains"
}, },
"disclaimer": { "disclaimer": {
"base": "Der Login erfolgt über den Browser, so dass Ihre Kontoinformationen für die Toot-App nicht sichtbar sind. Weitere Informationen", "base": "Der Login erfolgt über den Browser, so dass Ihre Kontoinformationen für die Toot-App nicht sichtbar sind."
"privacy": "Datenschutzbestimmungen" },
"terms": {
"base": ""
} }
}, },
"update": { "update": {

View File

@ -11,8 +11,10 @@
"domains": "Universes" "domains": "Universes"
}, },
"disclaimer": { "disclaimer": {
"base": "Logging in process uses system broswer that, your account information won't be visible to tooot app. Read more ", "base": "Logging in process uses system broswer that, your account information won't be visible to tooot app."
"privacy": "privacy policy" },
"terms": {
"base": "By logging in, you agree to the <0>privacy policy</0> and <1>terms of service</1>."
} }
}, },
"update": { "update": {

View File

@ -11,8 +11,10 @@
"domains": "Universi" "domains": "Universi"
}, },
"disclaimer": { "disclaimer": {
"base": "Per accedere, verrà aperta una pagina del browser di sistema. I dati di accesso del tuo account sono protetti. Leggi di più:", "base": "Per accedere, verrà aperta una pagina del browser di sistema. I dati di accesso del tuo account sono protetti."
"privacy": "politica sulla privacy" },
"terms": {
"base": ""
} }
}, },
"update": { "update": {

View File

@ -11,8 +11,10 @@
"domains": "연합" "domains": "연합"
}, },
"disclaimer": { "disclaimer": {
"base": "로그인 과정에서는 시스템 브라우저를 사용해, tooot 앱이 당신의 계정 정보를 볼 수 없어요.\n더 알아보기 ", "base": "로그인 과정에서는 시스템 브라우저를 사용해, tooot 앱이 당신의 계정 정보를 볼 수 없어요."
"privacy": "개인정보 정책" },
"terms": {
"base": ""
} }
}, },
"update": { "update": {

View File

@ -11,8 +11,10 @@
"domains": "Universo" "domains": "Universo"
}, },
"disclaimer": { "disclaimer": {
"base": "O processo de login usa o navegador do sistema e as informações da sua conta não estarão visíveis para o aplicativo Tooot. Consulte Mais informação ", "base": "O processo de login usa o navegador do sistema e as informações da sua conta não estarão visíveis para o aplicativo Tooot."
"privacy": "política de privacidade" },
"terms": {
"base": "Ao fazer o login, você concorda com a <0>política de privacidade</0> e os <1>termos de serviço</1>."
} }
}, },
"update": { "update": {

View File

@ -11,8 +11,10 @@
"domains": "Liên hợp" "domains": "Liên hợp"
}, },
"disclaimer": { "disclaimer": {
"base": "tooot sẽ không thấy được thông tin tài khoản của bạn. Tìm hiểu thêm ", "base": "tooot sẽ không thấy được thông tin tài khoản của bạn."
"privacy": "Bảo mật" },
"terms": {
"base": ""
} }
}, },
"update": { "update": {

View File

@ -11,8 +11,10 @@
"domains": "连结总数" "domains": "连结总数"
}, },
"disclaimer": { "disclaimer": {
"base": "登录过程将使用系统浏览器你的账号登录信息tooot应用无法读取。详见 ", "base": "登录过程将使用系统浏览器你的账号登录信息tooot应用无法读取。"
"privacy": "隐私条款" },
"terms": {
"base": "登录即表示您同意<0>隐私政策</0>和<1>服务条款</1>。"
} }
}, },
"update": { "update": {

View File

@ -11,8 +11,10 @@
"domains": "串聯宇宙" "domains": "串聯宇宙"
}, },
"disclaimer": { "disclaimer": {
"base": "將使用系統內建的瀏覽器來登入tooot app 無法讀取您的帳號資訊;詳見 ", "base": ""
"privacy": "隱私權政策" },
"terms": {
"base": ""
} }
}, },
"update": { "update": {