Bluesky app fork with some witchin' additions 💫

Merge pull request #3247 from bluesky-social/samuel/dynamic-translations

Fix instances of static translations (`t` macro)

authored by samuel.fm and committed by

GitHub 1dcd5c11 88ab83bd

+54 -32
+4 -4
src/view/com/composer/select-language/SelectLangBtn.tsx
··· 20 20 toPostLanguages, 21 21 hasPostLanguage, 22 22 } from '#/state/preferences/languages' 23 - import {t, msg} from '@lingui/macro' 23 + import {msg} from '@lingui/macro' 24 24 import {useLingui} from '@lingui/react' 25 25 26 26 export function SelectLangBtn() { ··· 84 84 } 85 85 86 86 return [ 87 - {heading: true, label: t`Post language`}, 87 + {heading: true, label: _(msg`Post language`)}, 88 88 ...arr.slice(0, 6), 89 89 {sep: true}, 90 90 { 91 - label: t`Other...`, 91 + label: _(msg`Other...`), 92 92 onPress: onPressMore, 93 93 }, 94 94 ] 95 - }, [onPressMore, langPrefs, setLangPrefs, postLanguagesPref]) 95 + }, [onPressMore, langPrefs, setLangPrefs, postLanguagesPref, _]) 96 96 97 97 return ( 98 98 <DropdownButton
+21 -16
src/view/com/lightbox/ImageViewing/components/ImageDefaultHeader.tsx
··· 6 6 * 7 7 */ 8 8 import React from 'react' 9 - import {createHitslop} from 'lib/constants' 10 9 import {SafeAreaView, Text, TouchableOpacity, StyleSheet} from 'react-native' 11 - import {t} from '@lingui/macro' 10 + import {msg} from '@lingui/macro' 11 + import {useLingui} from '@lingui/react' 12 + 13 + import {createHitslop} from '#/lib/constants' 12 14 13 15 type Props = { 14 16 onRequestClose: () => void ··· 16 18 17 19 const HIT_SLOP = createHitslop(16) 18 20 19 - const ImageDefaultHeader = ({onRequestClose}: Props) => ( 20 - <SafeAreaView style={styles.root}> 21 - <TouchableOpacity 22 - style={styles.closeButton} 23 - onPress={onRequestClose} 24 - hitSlop={HIT_SLOP} 25 - accessibilityRole="button" 26 - accessibilityLabel={t`Close image`} 27 - accessibilityHint={t`Closes viewer for header image`} 28 - onAccessibilityEscape={onRequestClose}> 29 - <Text style={styles.closeText}>✕</Text> 30 - </TouchableOpacity> 31 - </SafeAreaView> 32 - ) 21 + const ImageDefaultHeader = ({onRequestClose}: Props) => { 22 + const {_} = useLingui() 23 + return ( 24 + <SafeAreaView style={styles.root}> 25 + <TouchableOpacity 26 + style={styles.closeButton} 27 + onPress={onRequestClose} 28 + hitSlop={HIT_SLOP} 29 + accessibilityRole="button" 30 + accessibilityLabel={_(msg`Close image`)} 31 + accessibilityHint={_(msg`Closes viewer for header image`)} 32 + onAccessibilityEscape={onRequestClose}> 33 + <Text style={styles.closeText}>✕</Text> 34 + </TouchableOpacity> 35 + </SafeAreaView> 36 + ) 37 + } 33 38 34 39 const styles = StyleSheet.create({ 35 40 root: {
+5 -2
src/view/com/util/BottomSheetCustomBackdrop.tsx
··· 6 6 interpolate, 7 7 useAnimatedStyle, 8 8 } from 'react-native-reanimated' 9 - import {t} from '@lingui/macro' 9 + import {msg} from '@lingui/macro' 10 + import {useLingui} from '@lingui/react' 10 11 11 12 export function createCustomBackdrop( 12 13 onClose?: (() => void) | undefined, 13 14 ): React.FC<BottomSheetBackdropProps> { 14 15 const CustomBackdrop = ({animatedIndex, style}: BottomSheetBackdropProps) => { 16 + const {_} = useLingui() 17 + 15 18 // animated variables 16 19 const opacity = useAnimatedStyle(() => ({ 17 20 opacity: interpolate( ··· 30 33 return ( 31 34 <TouchableWithoutFeedback 32 35 onPress={onClose} 33 - accessibilityLabel={t`Close bottom drawer`} 36 + accessibilityLabel={_(msg`Close bottom drawer`)} 34 37 accessibilityHint="" 35 38 onAccessibilityEscape={() => { 36 39 if (onClose !== undefined) {
+17 -6
src/view/com/util/ErrorBoundary.tsx
··· 1 1 import React, {Component, ErrorInfo, ReactNode} from 'react' 2 2 import {ErrorScreen} from './error/ErrorScreen' 3 3 import {CenteredView} from './Views' 4 - import {t} from '@lingui/macro' 4 + import {msg} from '@lingui/macro' 5 5 import {logger} from '#/logger' 6 + import {useLingui} from '@lingui/react' 6 7 7 8 interface Props { 8 9 children?: ReactNode ··· 31 32 if (this.state.hasError) { 32 33 return ( 33 34 <CenteredView style={{height: '100%', flex: 1}}> 34 - <ErrorScreen 35 - title={t`Oh no!`} 36 - message={t`There was an unexpected issue in the application. Please let us know if this happened to you!`} 37 - details={this.state.error.toString()} 38 - /> 35 + <TranslatedErrorScreen details={this.state.error.toString()} /> 39 36 </CenteredView> 40 37 ) 41 38 } ··· 43 40 return this.props.children 44 41 } 45 42 } 43 + 44 + function TranslatedErrorScreen({details}: {details?: string}) { 45 + const {_} = useLingui() 46 + 47 + return ( 48 + <ErrorScreen 49 + title={_(msg`Oh no!`)} 50 + message={_( 51 + msg`There was an unexpected issue in the application. Please let us know if this happened to you!`, 52 + )} 53 + details={details} 54 + /> 55 + ) 56 + }
+7 -4
src/view/shell/index.web.tsx
··· 1 1 import React, {useEffect} from 'react' 2 2 import {View, StyleSheet, TouchableOpacity} from 'react-native' 3 + import {useNavigation} from '@react-navigation/native' 4 + import {msg} from '@lingui/macro' 5 + import {useLingui} from '@lingui/react' 6 + 3 7 import {ErrorBoundary} from '../com/util/ErrorBoundary' 4 8 import {Lightbox} from '../com/lightbox/Lightbox' 5 9 import {ModalsContainer} from '../com/modals/Modal' ··· 9 13 import {RoutesContainer, FlatNavigator} from '../../Navigation' 10 14 import {DrawerContent} from './Drawer' 11 15 import {useWebMediaQueries} from '../../lib/hooks/useWebMediaQueries' 12 - import {useNavigation} from '@react-navigation/native' 13 16 import {NavigationProp} from 'lib/routes/types' 14 - import {t} from '@lingui/macro' 15 17 import {useIsDrawerOpen, useSetDrawerOpen} from '#/state/shell' 16 18 import {useCloseAllActiveElements} from '#/state/util' 17 19 import {useWebBodyScrollLock} from '#/lib/hooks/useWebBodyScrollLock' ··· 24 26 const {isDesktop} = useWebMediaQueries() 25 27 const navigator = useNavigation<NavigationProp>() 26 28 const closeAllActiveElements = useCloseAllActiveElements() 29 + const {_} = useLingui() 27 30 28 31 useWebBodyScrollLock(isDrawerOpen) 29 32 ··· 48 51 <TouchableOpacity 49 52 onPress={() => setDrawerOpen(false)} 50 53 style={styles.drawerMask} 51 - accessibilityLabel={t`Close navigation footer`} 52 - accessibilityHint={t`Closes bottom navigation bar`}> 54 + accessibilityLabel={_(msg`Close navigation footer`)} 55 + accessibilityHint={_(msg`Closes bottom navigation bar`)}> 53 56 <View style={styles.drawerContainer}> 54 57 <DrawerContent /> 55 58 </View>