Fix toot relative time does not align with app's language

This commit is contained in:
xmflsct 2022-12-03 21:56:52 +01:00
parent 0fd3fcfd3f
commit 7421ffd1bc
4 changed files with 19 additions and 18 deletions

View File

@ -1,5 +1,4 @@
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'
@ -13,11 +12,12 @@ 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 } from '@utils/slices/settingsSlice'
import { changeLanguage, getSettingsLanguage } from '@utils/slices/settingsSlice'
import ThemeManager from '@utils/styles/ThemeManager'
import * as Localization from 'expo-localization'
import * as SplashScreen from 'expo-splash-screen'
import React, { useCallback, useEffect, useState } from 'react'
import { IntlProvider } from 'react-intl'
import { LogBox, Platform } from 'react-native'
import { GestureHandlerRootView } from 'react-native-gesture-handler'
import { SafeAreaProvider } from 'react-native-safe-area-context'
@ -85,7 +85,7 @@ const App: React.FC = () => {
if (bootstrapped) {
log('log', 'App', 'loading actual app :)')
log('log', 'App', `Locale: ${Localization.locale}`)
const language = getLanguage()
const language = getSettingsLanguage(store.getState())
if (!language) {
if (Platform.OS !== 'ios') {
store.dispatch(changeLanguage('en'))
@ -96,6 +96,7 @@ const App: React.FC = () => {
}
return (
<IntlProvider locale={language}>
<SafeAreaProvider>
<ActionSheetProvider>
<AccessibilityManager>
@ -105,6 +106,7 @@ const App: React.FC = () => {
</AccessibilityManager>
</ActionSheetProvider>
</SafeAreaProvider>
</IntlProvider>
)
} else {
return null

View File

@ -27,7 +27,6 @@ import * as Linking from 'expo-linking'
import { addScreenshotListener } from 'expo-screen-capture'
import React, { useCallback, useEffect, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { IntlProvider } from 'react-intl'
import { Alert, Platform, StatusBar } from 'react-native'
import ShareMenu from 'react-native-share-menu'
import { useSelector } from 'react-redux'
@ -271,7 +270,7 @@ const Screens: React.FC<Props> = ({ localCorrupt }) => {
}, [])
return (
<IntlProvider locale={i18n.language}>
<>
<StatusBar
backgroundColor={colors.backgroundDefault}
{...(Platform.OS === 'android' && {
@ -348,7 +347,7 @@ const Screens: React.FC<Props> = ({ localCorrupt }) => {
<Message />
</NavigationContainer>
</IntlProvider>
</>
)
}

View File

@ -9,7 +9,7 @@ export interface Props {
const RelativeTime: React.FC<Props> = ({ time }) => {
const [now, setNow] = useState(new Date().getTime())
useEffect(() => {
const appStateListener = AppState.addEventListener('change', state => {
const appStateListener = AppState.addEventListener('change', () => {
setNow(new Date().getTime())
})

View File

@ -2,10 +2,10 @@ import * as Localization from 'expo-localization'
import log from './log'
const timezone = () => {
log('log', 'Timezone', Localization.timezone)
log('log', 'Timezone', Localization.getCalendars()[0].timeZone || 'unknown')
if ('__setDefaultTimeZone' in Intl.DateTimeFormat) {
// @ts-ignore
Intl.DateTimeFormat.__setDefaultTimeZone(Localization.timezone)
Intl.DateTimeFormat.__setDefaultTimeZone(Localization.getCalendars()[0].timeZone)
}
}