Plural formatting for accessibility unread items strings (#7743)
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import React, {ComponentProps} from 'react'
|
import React, {ComponentProps} from 'react'
|
||||||
import {Linking, ScrollView, TouchableOpacity, View} from 'react-native'
|
import {Linking, ScrollView, TouchableOpacity, View} from 'react-native'
|
||||||
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
||||||
import {msg, Plural, Trans} from '@lingui/macro'
|
import {msg, Plural, plural, Trans} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
import {StackActions, useNavigation} from '@react-navigation/native'
|
import {StackActions, useNavigation} from '@react-navigation/native'
|
||||||
|
|
||||||
@@ -450,7 +450,12 @@ let NotificationsMenuItem = ({
|
|||||||
accessibilityHint={
|
accessibilityHint={
|
||||||
numUnreadNotifications === ''
|
numUnreadNotifications === ''
|
||||||
? ''
|
? ''
|
||||||
: _(msg`${numUnreadNotifications} unread`)
|
: _(
|
||||||
|
msg`${plural(numUnreadNotifications ?? 0, {
|
||||||
|
one: '# unread item',
|
||||||
|
other: '# unread items',
|
||||||
|
})}` || '',
|
||||||
|
)
|
||||||
}
|
}
|
||||||
count={numUnreadNotifications}
|
count={numUnreadNotifications}
|
||||||
bold={isActive}
|
bold={isActive}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React, {ComponentProps} from 'react'
|
|||||||
import {GestureResponderEvent, View} from 'react-native'
|
import {GestureResponderEvent, View} from 'react-native'
|
||||||
import Animated from 'react-native-reanimated'
|
import Animated from 'react-native-reanimated'
|
||||||
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
||||||
import {msg, Trans} from '@lingui/macro'
|
import {msg, plural, Trans} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
import {BottomTabBarProps} from '@react-navigation/bottom-tabs'
|
import {BottomTabBarProps} from '@react-navigation/bottom-tabs'
|
||||||
import {StackActions} from '@react-navigation/native'
|
import {StackActions} from '@react-navigation/native'
|
||||||
@@ -204,7 +204,12 @@ export function BottomBar({navigation}: BottomTabBarProps) {
|
|||||||
accessibilityLabel={_(msg`Chat`)}
|
accessibilityLabel={_(msg`Chat`)}
|
||||||
accessibilityHint={
|
accessibilityHint={
|
||||||
numUnreadMessages.count > 0
|
numUnreadMessages.count > 0
|
||||||
? _(msg`${numUnreadMessages.numUnread} unread items`)
|
? _(
|
||||||
|
msg`${plural(numUnreadMessages.numUnread ?? 0, {
|
||||||
|
one: '# unread item',
|
||||||
|
other: '# unread items',
|
||||||
|
})}` || '',
|
||||||
|
)
|
||||||
: ''
|
: ''
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
@@ -231,7 +236,12 @@ export function BottomBar({navigation}: BottomTabBarProps) {
|
|||||||
accessibilityHint={
|
accessibilityHint={
|
||||||
numUnreadNotifications === ''
|
numUnreadNotifications === ''
|
||||||
? ''
|
? ''
|
||||||
: _(msg`${numUnreadNotifications} unread items`)
|
: _(
|
||||||
|
msg`${plural(numUnreadNotifications ?? 0, {
|
||||||
|
one: '# unread item',
|
||||||
|
other: '# unread items',
|
||||||
|
})}` || '',
|
||||||
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Btn
|
<Btn
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import Animated from 'react-native-reanimated'
|
import Animated from 'react-native-reanimated'
|
||||||
import {msg, Trans} from '@lingui/macro'
|
import {msg, plural, Trans} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
import {useNavigationState} from '@react-navigation/native'
|
import {useNavigationState} from '@react-navigation/native'
|
||||||
|
|
||||||
@@ -269,7 +269,12 @@ const NavItem: React.FC<{
|
|||||||
{notificationCount ? (
|
{notificationCount ? (
|
||||||
<View
|
<View
|
||||||
style={styles.notificationCount}
|
style={styles.notificationCount}
|
||||||
aria-label={_(msg`${notificationCount} unread items`)}>
|
aria-label={_(
|
||||||
|
msg`${plural(notificationCount, {
|
||||||
|
one: '# unread item',
|
||||||
|
other: '# unread items',
|
||||||
|
})}`,
|
||||||
|
)}>
|
||||||
<Text style={styles.notificationCountLabel}>{notificationCount}</Text>
|
<Text style={styles.notificationCountLabel}>{notificationCount}</Text>
|
||||||
</View>
|
</View>
|
||||||
) : hasNew ? (
|
) : hasNew ? (
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React from 'react'
|
|||||||
import {StyleSheet, View} from 'react-native'
|
import {StyleSheet, View} from 'react-native'
|
||||||
import {AppBskyActorDefs} from '@atproto/api'
|
import {AppBskyActorDefs} from '@atproto/api'
|
||||||
import {FontAwesomeIconStyle} from '@fortawesome/react-native-fontawesome'
|
import {FontAwesomeIconStyle} from '@fortawesome/react-native-fontawesome'
|
||||||
import {msg, Trans} from '@lingui/macro'
|
import {msg, plural, Trans} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
import {
|
import {
|
||||||
useLinkProps,
|
useLinkProps,
|
||||||
@@ -384,7 +384,12 @@ function NavItem({count, hasNew, href, icon, iconFilled, label}: NavItemProps) {
|
|||||||
{right: -20}, // more breathing room
|
{right: -20}, // more breathing room
|
||||||
]}>
|
]}>
|
||||||
<Text
|
<Text
|
||||||
accessibilityLabel={_(msg`${count} unread items`)}
|
accessibilityLabel={_(
|
||||||
|
msg`${plural(count, {
|
||||||
|
one: '# unread item',
|
||||||
|
other: '# unread items',
|
||||||
|
})}`,
|
||||||
|
)}
|
||||||
accessibilityHint=""
|
accessibilityHint=""
|
||||||
accessible={true}
|
accessible={true}
|
||||||
numberOfLines={1}
|
numberOfLines={1}
|
||||||
|
|||||||
Reference in New Issue
Block a user