change usage of t to msg

zio/stable
Samuel Newman 2024-03-18 14:37:30 +00:00
parent 98bca69ae9
commit fbfb78b860
5 changed files with 54 additions and 32 deletions

View File

@ -20,7 +20,7 @@ import {
toPostLanguages, toPostLanguages,
hasPostLanguage, hasPostLanguage,
} from '#/state/preferences/languages' } from '#/state/preferences/languages'
import {t, msg} from '@lingui/macro' import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
export function SelectLangBtn() { export function SelectLangBtn() {
@ -84,15 +84,15 @@ export function SelectLangBtn() {
} }
return [ return [
{heading: true, label: t`Post language`}, {heading: true, label: _(msg`Post language`)},
...arr.slice(0, 6), ...arr.slice(0, 6),
{sep: true}, {sep: true},
{ {
label: t`Other...`, label: _(`Other...`),
onPress: onPressMore, onPress: onPressMore,
}, },
] ]
}, [onPressMore, langPrefs, setLangPrefs, postLanguagesPref]) }, [onPressMore, langPrefs, setLangPrefs, postLanguagesPref, _])
return ( return (
<DropdownButton <DropdownButton

View File

@ -6,9 +6,11 @@
* *
*/ */
import React from 'react' import React from 'react'
import {createHitslop} from 'lib/constants'
import {SafeAreaView, Text, TouchableOpacity, StyleSheet} from 'react-native' import {SafeAreaView, Text, TouchableOpacity, StyleSheet} from 'react-native'
import {t} from '@lingui/macro' import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {createHitslop} from '#/lib/constants'
type Props = { type Props = {
onRequestClose: () => void onRequestClose: () => void
@ -16,20 +18,23 @@ type Props = {
const HIT_SLOP = createHitslop(16) const HIT_SLOP = createHitslop(16)
const ImageDefaultHeader = ({onRequestClose}: Props) => ( const ImageDefaultHeader = ({onRequestClose}: Props) => {
<SafeAreaView style={styles.root}> const {_} = useLingui()
<TouchableOpacity return (
style={styles.closeButton} <SafeAreaView style={styles.root}>
onPress={onRequestClose} <TouchableOpacity
hitSlop={HIT_SLOP} style={styles.closeButton}
accessibilityRole="button" onPress={onRequestClose}
accessibilityLabel={t`Close image`} hitSlop={HIT_SLOP}
accessibilityHint={t`Closes viewer for header image`} accessibilityRole="button"
onAccessibilityEscape={onRequestClose}> accessibilityLabel={_(msg`Close image`)}
<Text style={styles.closeText}></Text> accessibilityHint={_(msg`Closes viewer for header image`)}
</TouchableOpacity> onAccessibilityEscape={onRequestClose}>
</SafeAreaView> <Text style={styles.closeText}></Text>
) </TouchableOpacity>
</SafeAreaView>
)
}
const styles = StyleSheet.create({ const styles = StyleSheet.create({
root: { root: {

View File

@ -6,12 +6,15 @@ import Animated, {
interpolate, interpolate,
useAnimatedStyle, useAnimatedStyle,
} from 'react-native-reanimated' } from 'react-native-reanimated'
import {t} from '@lingui/macro' import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
export function createCustomBackdrop( export function createCustomBackdrop(
onClose?: (() => void) | undefined, onClose?: (() => void) | undefined,
): React.FC<BottomSheetBackdropProps> { ): React.FC<BottomSheetBackdropProps> {
const CustomBackdrop = ({animatedIndex, style}: BottomSheetBackdropProps) => { const CustomBackdrop = ({animatedIndex, style}: BottomSheetBackdropProps) => {
const {_} = useLingui()
// animated variables // animated variables
const opacity = useAnimatedStyle(() => ({ const opacity = useAnimatedStyle(() => ({
opacity: interpolate( opacity: interpolate(
@ -30,7 +33,7 @@ export function createCustomBackdrop(
return ( return (
<TouchableWithoutFeedback <TouchableWithoutFeedback
onPress={onClose} onPress={onClose}
accessibilityLabel={t`Close bottom drawer`} accessibilityLabel={_(msg`Close bottom drawer`)}
accessibilityHint="" accessibilityHint=""
onAccessibilityEscape={() => { onAccessibilityEscape={() => {
if (onClose !== undefined) { if (onClose !== undefined) {

View File

@ -1,8 +1,9 @@
import React, {Component, ErrorInfo, ReactNode} from 'react' import React, {Component, ErrorInfo, ReactNode} from 'react'
import {ErrorScreen} from './error/ErrorScreen' import {ErrorScreen} from './error/ErrorScreen'
import {CenteredView} from './Views' import {CenteredView} from './Views'
import {t} from '@lingui/macro' import {msg} from '@lingui/macro'
import {logger} from '#/logger' import {logger} from '#/logger'
import {useLingui} from '@lingui/react'
interface Props { interface Props {
children?: ReactNode children?: ReactNode
@ -31,11 +32,7 @@ export class ErrorBoundary extends Component<Props, State> {
if (this.state.hasError) { if (this.state.hasError) {
return ( return (
<CenteredView style={{height: '100%', flex: 1}}> <CenteredView style={{height: '100%', flex: 1}}>
<ErrorScreen <TranslatedErrorScreen details={this.state.error.toString()} />
title={t`Oh no!`}
message={t`There was an unexpected issue in the application. Please let us know if this happened to you!`}
details={this.state.error.toString()}
/>
</CenteredView> </CenteredView>
) )
} }
@ -43,3 +40,17 @@ export class ErrorBoundary extends Component<Props, State> {
return this.props.children return this.props.children
} }
} }
function TranslatedErrorScreen({details}: {details?: string}) {
const {_} = useLingui()
return (
<ErrorScreen
title={_(msg`Oh no!`)}
message={_(
msg`There was an unexpected issue in the application. Please let us know if this happened to you!`,
)}
details={details}
/>
)
}

View File

@ -1,5 +1,9 @@
import React, {useEffect} from 'react' import React, {useEffect} from 'react'
import {View, StyleSheet, TouchableOpacity} from 'react-native' import {View, StyleSheet, TouchableOpacity} from 'react-native'
import {useNavigation} from '@react-navigation/native'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {ErrorBoundary} from '../com/util/ErrorBoundary' import {ErrorBoundary} from '../com/util/ErrorBoundary'
import {Lightbox} from '../com/lightbox/Lightbox' import {Lightbox} from '../com/lightbox/Lightbox'
import {ModalsContainer} from '../com/modals/Modal' import {ModalsContainer} from '../com/modals/Modal'
@ -9,9 +13,7 @@ import {s, colors} from 'lib/styles'
import {RoutesContainer, FlatNavigator} from '../../Navigation' import {RoutesContainer, FlatNavigator} from '../../Navigation'
import {DrawerContent} from './Drawer' import {DrawerContent} from './Drawer'
import {useWebMediaQueries} from '../../lib/hooks/useWebMediaQueries' import {useWebMediaQueries} from '../../lib/hooks/useWebMediaQueries'
import {useNavigation} from '@react-navigation/native'
import {NavigationProp} from 'lib/routes/types' import {NavigationProp} from 'lib/routes/types'
import {t} from '@lingui/macro'
import {useIsDrawerOpen, useSetDrawerOpen} from '#/state/shell' import {useIsDrawerOpen, useSetDrawerOpen} from '#/state/shell'
import {useCloseAllActiveElements} from '#/state/util' import {useCloseAllActiveElements} from '#/state/util'
import {useWebBodyScrollLock} from '#/lib/hooks/useWebBodyScrollLock' import {useWebBodyScrollLock} from '#/lib/hooks/useWebBodyScrollLock'
@ -24,6 +26,7 @@ function ShellInner() {
const {isDesktop} = useWebMediaQueries() const {isDesktop} = useWebMediaQueries()
const navigator = useNavigation<NavigationProp>() const navigator = useNavigation<NavigationProp>()
const closeAllActiveElements = useCloseAllActiveElements() const closeAllActiveElements = useCloseAllActiveElements()
const {_} = useLingui()
useWebBodyScrollLock(isDrawerOpen) useWebBodyScrollLock(isDrawerOpen)
@ -48,8 +51,8 @@ function ShellInner() {
<TouchableOpacity <TouchableOpacity
onPress={() => setDrawerOpen(false)} onPress={() => setDrawerOpen(false)}
style={styles.drawerMask} style={styles.drawerMask}
accessibilityLabel={t`Close navigation footer`} accessibilityLabel={_(msg`Close navigation footer`)}
accessibilityHint={t`Closes bottom navigation bar`}> accessibilityHint={_(msg`Closes bottom navigation bar`)}>
<View style={styles.drawerContainer}> <View style={styles.drawerContainer}>
<DrawerContent /> <DrawerContent />
</View> </View>