diff options
Diffstat (limited to 'src/view/com')
-rw-r--r-- | src/view/com/feeds/FeedSourceCard.tsx | 12 | ||||
-rw-r--r-- | src/view/com/notifications/FeedItem.tsx | 10 | ||||
-rw-r--r-- | src/view/com/post-thread/PostThreadItem.tsx | 12 | ||||
-rw-r--r-- | src/view/com/util/post-ctrls/PostCtrls.tsx | 24 | ||||
-rw-r--r-- | src/view/com/util/post-ctrls/RepostButton.tsx | 5 |
5 files changed, 38 insertions, 25 deletions
diff --git a/src/view/com/feeds/FeedSourceCard.tsx b/src/view/com/feeds/FeedSourceCard.tsx index 9300b4159..8a21d86ae 100644 --- a/src/view/com/feeds/FeedSourceCard.tsx +++ b/src/view/com/feeds/FeedSourceCard.tsx @@ -6,12 +6,11 @@ import {RichText} from '#/components/RichText' import {usePalette} from 'lib/hooks/usePalette' import {s} from 'lib/styles' import {UserAvatar} from '../util/UserAvatar' -import {pluralize} from 'lib/strings/helpers' import {AtUri} from '@atproto/api' import * as Toast from 'view/com/util/Toast' import {sanitizeHandle} from 'lib/strings/handles' import {logger} from '#/logger' -import {Trans, msg} from '@lingui/macro' +import {Trans, msg, Plural} from '@lingui/macro' import {useLingui} from '@lingui/react' import { usePinFeedMutation, @@ -265,10 +264,11 @@ export function FeedSourceCardLoaded({ {showLikes && feed.type === 'feed' ? ( <Text type="sm-medium" style={[pal.text, pal.textLight]}> - <Trans> - Liked by {feed.likeCount || 0}{' '} - {pluralize(feed.likeCount || 0, 'user')} - </Trans> + <Plural + value={feed.likeCount || 0} + one="Liked by # user" + other="Liked by # users" + /> </Text> ) : null} </Pressable> diff --git a/src/view/com/notifications/FeedItem.tsx b/src/view/com/notifications/FeedItem.tsx index 94844cb1a..c20a8e9ee 100644 --- a/src/view/com/notifications/FeedItem.tsx +++ b/src/view/com/notifications/FeedItem.tsx @@ -22,7 +22,7 @@ import { FontAwesomeIconStyle, Props, } from '@fortawesome/react-native-fontawesome' -import {msg, Trans} from '@lingui/macro' +import {msg, plural, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {useQueryClient} from '@tanstack/react-query' @@ -33,7 +33,6 @@ import {HeartIconSolid} from 'lib/icons' import {makeProfileLink} from 'lib/routes/links' import {sanitizeDisplayName} from 'lib/strings/display-names' import {sanitizeHandle} from 'lib/strings/handles' -import {pluralize} from 'lib/strings/helpers' import {niceDate} from 'lib/strings/time' import {colors, s} from 'lib/styles' import {isWeb} from 'platform/detection' @@ -176,6 +175,7 @@ let FeedItem = ({ return null } + let formattedCount = authors.length > 1 ? formatCount(authors.length - 1) : '' return ( <Link testID={`feedItem-by-${item.notification.author.handle}`} @@ -236,8 +236,10 @@ let FeedItem = ({ <Trans>and</Trans>{' '} </Text> <Text style={[pal.text, s.bold]}> - {formatCount(authors.length - 1)}{' '} - {pluralize(authors.length - 1, 'other')} + {plural(authors.length - 1, { + one: `${formattedCount} other`, + other: `${formattedCount} others`, + })} </Text> </> ) : undefined} diff --git a/src/view/com/post-thread/PostThreadItem.tsx b/src/view/com/post-thread/PostThreadItem.tsx index cfb8bd93f..f644a5366 100644 --- a/src/view/com/post-thread/PostThreadItem.tsx +++ b/src/view/com/post-thread/PostThreadItem.tsx @@ -8,7 +8,7 @@ import { RichText as RichTextAPI, } from '@atproto/api' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' -import {msg, Trans} from '@lingui/macro' +import {msg, Plural, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {moderatePost_wrapped as moderatePost} from '#/lib/moderatePost_wrapped' @@ -24,7 +24,7 @@ import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries' import {makeProfileLink} from 'lib/routes/links' import {sanitizeDisplayName} from 'lib/strings/display-names' import {sanitizeHandle} from 'lib/strings/handles' -import {countLines, pluralize} from 'lib/strings/helpers' +import {countLines} from 'lib/strings/helpers' import {niceDate} from 'lib/strings/time' import {s} from 'lib/styles' import {isWeb} from 'platform/detection' @@ -336,7 +336,11 @@ let PostThreadItemLoaded = ({ <Text type="xl-bold" style={pal.text}> {formatCount(post.repostCount)} </Text>{' '} - {pluralize(post.repostCount, 'repost')} + <Plural + value={post.repostCount} + one="repost" + other="reposts" + /> </Text> </Link> ) : null} @@ -352,7 +356,7 @@ let PostThreadItemLoaded = ({ <Text type="xl-bold" style={pal.text}> {formatCount(post.likeCount)} </Text>{' '} - {pluralize(post.likeCount, 'like')} + <Plural value={post.likeCount} one="like" other="likes" /> </Text> </Link> ) : null} diff --git a/src/view/com/util/post-ctrls/PostCtrls.tsx b/src/view/com/util/post-ctrls/PostCtrls.tsx index cb50ee6dc..7ebcde9a0 100644 --- a/src/view/com/util/post-ctrls/PostCtrls.tsx +++ b/src/view/com/util/post-ctrls/PostCtrls.tsx @@ -12,14 +12,13 @@ import { AtUri, RichText as RichTextAPI, } from '@atproto/api' -import {msg} from '@lingui/macro' +import {msg, plural} from '@lingui/macro' import {useLingui} from '@lingui/react' import {HITSLOP_10, HITSLOP_20} from '#/lib/constants' import {CommentBottomArrow, HeartIcon, HeartIconSolid} from '#/lib/icons' import {makeProfileLink} from '#/lib/routes/links' import {shareUrl} from '#/lib/sharing' -import {pluralize} from '#/lib/strings/helpers' import {toShareUrl} from '#/lib/strings/url-helpers' import {s} from '#/lib/styles' import {useTheme} from '#/lib/ThemeContext' @@ -159,9 +158,10 @@ let PostCtrls = ({ } }} accessibilityRole="button" - accessibilityLabel={`Reply (${post.replyCount} ${ - post.replyCount === 1 ? 'reply' : 'replies' - })`} + accessibilityLabel={plural(post.replyCount || 0, { + one: 'Reply (# reply)', + other: 'Reply (# replies)', + })} accessibilityHint="" hitSlop={big ? HITSLOP_20 : HITSLOP_10}> <CommentBottomArrow @@ -193,9 +193,17 @@ let PostCtrls = ({ requireAuth(() => onPressToggleLike()) }} accessibilityRole="button" - accessibilityLabel={`${ - post.viewer?.like ? _(msg`Unlike`) : _(msg`Like`) - } (${post.likeCount} ${pluralize(post.likeCount || 0, 'like')})`} + accessibilityLabel={ + post.viewer?.like + ? plural(post.likeCount || 0, { + one: 'Unlike (# like)', + other: 'Unlike (# likes)', + }) + : plural(post.likeCount || 0, { + one: 'Like (# like)', + other: 'Like (# likes)', + }) + } accessibilityHint="" hitSlop={big ? HITSLOP_20 : HITSLOP_10}> {post.viewer?.like ? ( diff --git a/src/view/com/util/post-ctrls/RepostButton.tsx b/src/view/com/util/post-ctrls/RepostButton.tsx index cc3db50c8..c1af39a5d 100644 --- a/src/view/com/util/post-ctrls/RepostButton.tsx +++ b/src/view/com/util/post-ctrls/RepostButton.tsx @@ -4,11 +4,10 @@ import {RepostIcon} from 'lib/icons' import {s, colors} from 'lib/styles' import {useTheme} from 'lib/ThemeContext' import {Text} from '../text/Text' -import {pluralize} from 'lib/strings/helpers' import {HITSLOP_10, HITSLOP_20} from 'lib/constants' import {useModalControls} from '#/state/modals' import {useRequireAuth} from '#/state/session' -import {msg} from '@lingui/macro' +import {msg, plural} from '@lingui/macro' import {useLingui} from '@lingui/react' interface Props { @@ -59,7 +58,7 @@ let RepostButton = ({ isReposted ? _(msg`Undo repost`) : _(msg({message: 'Repost', context: 'action'})) - } (${repostCount} ${pluralize(repostCount || 0, 'repost')})`} + } (${plural(repostCount || 0, {one: '# repost', other: '# reposts'})})`} accessibilityHint="" hitSlop={big ? HITSLOP_20 : HITSLOP_10}> <RepostIcon |