mirror of
https://github.com/tooot-app/app
synced 2025-01-03 05:00:34 +01:00
parent
4b1d628c5e
commit
0d9992107c
@ -1,4 +1,5 @@
|
||||
import { ActionSheetProvider } from '@expo/react-native-action-sheet'
|
||||
import getLanguage from '@helpers/getLanguage'
|
||||
import queryClient from '@helpers/queryClient'
|
||||
import i18n from '@root/i18n/i18n'
|
||||
import Screens from '@root/Screens'
|
||||
@ -12,7 +13,7 @@ import timezone from '@root/startup/timezone'
|
||||
import { persistor, store } from '@root/store'
|
||||
import * as Sentry from '@sentry/react-native'
|
||||
import AccessibilityManager from '@utils/accessibility/AccessibilityManager'
|
||||
import { changeLanguage, getSettingsLanguage } from '@utils/slices/settingsSlice'
|
||||
import { changeLanguage } from '@utils/slices/settingsSlice'
|
||||
import ThemeManager from '@utils/styles/ThemeManager'
|
||||
import * as Localization from 'expo-localization'
|
||||
import * as SplashScreen from 'expo-splash-screen'
|
||||
@ -83,10 +84,7 @@ const App: React.FC = () => {
|
||||
if (bootstrapped) {
|
||||
log('log', 'App', 'loading actual app :)')
|
||||
log('log', 'App', `Locale: ${Localization.locale}`)
|
||||
const language =
|
||||
Platform.OS === 'ios'
|
||||
? Localization.locale
|
||||
: getSettingsLanguage(store.getState())
|
||||
const language = getLanguage()
|
||||
if (!language) {
|
||||
if (Platform.OS !== 'ios') {
|
||||
store.dispatch(changeLanguage('en'))
|
||||
|
@ -1,8 +1,8 @@
|
||||
import analytics from '@components/analytics'
|
||||
import { ParseHTML } from '@components/Parse'
|
||||
import CustomText from '@components/Text'
|
||||
import getLanguage from '@helpers/getLanguage'
|
||||
import { useTranslateQuery } from '@utils/queryHooks/translate'
|
||||
import { getSettingsLanguage } from '@utils/slices/settingsSlice'
|
||||
import { StyleConstants } from '@utils/styles/constants'
|
||||
import { useTheme } from '@utils/styles/ThemeManager'
|
||||
import * as Localization from 'expo-localization'
|
||||
@ -11,14 +11,10 @@ import { useTranslation } from 'react-i18next'
|
||||
import { Pressable } from 'react-native'
|
||||
import { Circle } from 'react-native-animated-spinkit'
|
||||
import detectLanguage from 'react-native-language-detection'
|
||||
import { useSelector } from 'react-redux'
|
||||
|
||||
export interface Props {
|
||||
highlighted: boolean
|
||||
status: Pick<
|
||||
Mastodon.Status,
|
||||
'language' | 'spoiler_text' | 'content' | 'emojis'
|
||||
>
|
||||
status: Pick<Mastodon.Status, 'language' | 'spoiler_text' | 'content' | 'emojis'>
|
||||
}
|
||||
|
||||
const TimelineTranslate = React.memo(
|
||||
@ -30,9 +26,7 @@ const TimelineTranslate = React.memo(
|
||||
const { t } = useTranslation('componentTimeline')
|
||||
const { colors } = useTheme()
|
||||
|
||||
const text = status.spoiler_text
|
||||
? [status.spoiler_text, status.content]
|
||||
: [status.content]
|
||||
const text = status.spoiler_text ? [status.spoiler_text, status.content] : [status.content]
|
||||
|
||||
for (const i in text) {
|
||||
for (const emoji of status.emojis) {
|
||||
@ -56,7 +50,7 @@ const TimelineTranslate = React.memo(
|
||||
detect()
|
||||
}, [])
|
||||
|
||||
const settingsLanguage = useSelector(getSettingsLanguage)
|
||||
const settingsLanguage = getLanguage()
|
||||
const targetLanguage = settingsLanguage?.startsWith('en')
|
||||
? Localization.locale || settingsLanguage || 'en'
|
||||
: settingsLanguage || Localization.locale || 'en'
|
||||
@ -107,12 +101,7 @@ const TimelineTranslate = React.memo(
|
||||
<CustomText
|
||||
fontStyle='M'
|
||||
style={{
|
||||
color:
|
||||
isLoading || isSuccess
|
||||
? colors.secondary
|
||||
: isError
|
||||
? colors.red
|
||||
: colors.blue
|
||||
color: isLoading || isSuccess ? colors.secondary : isError ? colors.red : colors.blue
|
||||
}}
|
||||
>
|
||||
{isError
|
||||
@ -127,9 +116,7 @@ const TimelineTranslate = React.memo(
|
||||
: t('shared.translate.default')}
|
||||
</CustomText>
|
||||
<CustomText>
|
||||
{__DEV__
|
||||
? ` Source: ${detectedLanguage}; Target: ${targetLanguage}`
|
||||
: undefined}
|
||||
{__DEV__ ? ` Source: ${detectedLanguage}; Target: ${targetLanguage}` : undefined}
|
||||
</CustomText>
|
||||
{isLoading ? (
|
||||
<Circle
|
||||
|
12
src/helpers/getLanguage.ts
Normal file
12
src/helpers/getLanguage.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { store } from '@root/store'
|
||||
import { getSettingsLanguage } from '@utils/slices/settingsSlice'
|
||||
import * as Localization from 'expo-localization'
|
||||
import { Platform } from "react-native"
|
||||
|
||||
const getLanguage = (): string => {
|
||||
return Platform.OS === 'ios'
|
||||
? Localization.locale
|
||||
: getSettingsLanguage(store.getState())
|
||||
}
|
||||
|
||||
export default getLanguage
|
Loading…
Reference in New Issue
Block a user