refine plural marks (#7065)

This commit is contained in:
Minseo Lee
2024-12-12 12:48:02 +09:00
committed by GitHub
parent ddeadc21a0
commit 084905c146
8 changed files with 83 additions and 54 deletions
+4 -5
View File
@@ -7,7 +7,7 @@ import {
AtUri, AtUri,
RichText as RichTextApi, RichText as RichTextApi,
} from '@atproto/api' } from '@atproto/api'
import {msg, plural, Trans} from '@lingui/macro' import {msg, Plural, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {useQueryClient} from '@tanstack/react-query' import {useQueryClient} from '@tanstack/react-query'
@@ -210,10 +210,9 @@ export function Likes({count}: {count: number}) {
const t = useTheme() const t = useTheme()
return ( return (
<Text style={[a.text_sm, t.atoms.text_contrast_medium]}> <Text style={[a.text_sm, t.atoms.text_contrast_medium]}>
{plural(count || 0, { <Trans>
one: 'Liked by # user', Liked by <Plural value={count || 0} one="# user" other="# users" />
other: 'Liked by # users', </Trans>
})}
</Text> </Text>
) )
} }
+5 -3
View File
@@ -83,7 +83,7 @@ export function RegionalNotice() {
) )
} }
export function LikeCount({count}: {count: number}) { export function LikeCount({likeCount}: {likeCount: number}) {
const t = useTheme() const t = useTheme()
return ( return (
<Text <Text
@@ -93,7 +93,9 @@ export function LikeCount({count}: {count: number}) {
t.atoms.text_contrast_medium, t.atoms.text_contrast_medium,
{fontWeight: '600'}, {fontWeight: '600'},
]}> ]}>
<Plural value={count} one="Liked by # user" other="Liked by # users" /> <Trans>
Liked by <Plural value={likeCount} one="# user" other="# users" />
</Trans>
</Text> </Text>
) )
} }
@@ -138,7 +140,7 @@ export function Default({
value={labeler.creator.description} value={labeler.creator.description}
handle={labeler.creator.handle} handle={labeler.creator.handle}
/> />
{labeler.likeCount ? <LikeCount count={labeler.likeCount} /> : null} {labeler.likeCount ? <LikeCount likeCount={labeler.likeCount} /> : null}
</Content> </Content>
</Outer> </Outer>
) )
+17 -11
View File
@@ -1,6 +1,6 @@
import {StyleProp, View, ViewStyle} from 'react-native' import {StyleProp, View, ViewStyle} from 'react-native'
import {AppBskyFeedDefs, ComAtprotoLabelDefs} from '@atproto/api' import {AppBskyFeedDefs, ComAtprotoLabelDefs} from '@atproto/api'
import {msg, Plural} from '@lingui/macro' import {msg, Plural, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {useSession} from '#/state/session' import {useSession} from '#/state/session'
@@ -50,17 +50,23 @@ export function LabelsOnMe({
<ButtonIcon position="left" icon={CircleInfo} /> <ButtonIcon position="left" icon={CircleInfo} />
<ButtonText style={[a.leading_snug]}> <ButtonText style={[a.leading_snug]}>
{type === 'account' ? ( {type === 'account' ? (
<Plural <Trans>
value={labels.length} <Plural
one="# label has been placed on this account" value={labels.length}
other="# labels have been placed on this account" one="# label has"
/> other="# labels have"
/>{' '}
been placed on this account
</Trans>
) : ( ) : (
<Plural <Trans>
value={labels.length} <Plural
one="# label has been placed on this content" value={labels.length}
other="# labels have been placed on this content" one="# label has"
/> other="# labels have"
/>{' '}
been placed on this content
</Trans>
)} )}
</ButtonText> </ButtonText>
</Button> </Button>
@@ -291,10 +291,12 @@ let ProfileHeaderLabeler = ({
}, },
}} }}
size="tiny" size="tiny"
label={plural(likeCount, { label={_(
one: 'Liked by # user', msg`Liked by ${plural(likeCount, {
other: 'Liked by # users', one: '# user',
})}> other: '# users',
})}`,
)}>
{({hovered, focused, pressed}) => ( {({hovered, focused, pressed}) => (
<Text <Text
style={[ style={[
@@ -304,11 +306,14 @@ let ProfileHeaderLabeler = ({
(hovered || focused || pressed) && (hovered || focused || pressed) &&
t.atoms.text_contrast_high, t.atoms.text_contrast_high,
]}> ]}>
<Plural <Trans>
value={likeCount} Liked by{' '}
one="Liked by # user" <Plural
other="Liked by # users" value={likeCount}
/> one="# user"
other="# users"
/>
</Trans>
</Text> </Text>
)} )}
</Link> </Link>
+8 -5
View File
@@ -300,11 +300,14 @@ export function FeedSourceCardLoaded({
{showLikes && feed.type === 'feed' ? ( {showLikes && feed.type === 'feed' ? (
<Text type="sm-medium" style={[pal.text, pal.textLight]}> <Text type="sm-medium" style={[pal.text, pal.textLight]}>
<Plural <Trans>
value={feed.likeCount || 0} Liked by{' '}
one="Liked by # user" <Plural
other="Liked by # users" value={feed.likeCount || 0}
/> one="# user"
other="# users"
/>
</Trans>
</Text> </Text>
) : null} ) : null}
</Pressable> </Pressable>
+18 -12
View File
@@ -258,10 +258,12 @@ let PostCtrls = ({
} }
}} }}
accessibilityRole="button" accessibilityRole="button"
accessibilityLabel={plural(post.replyCount || 0, { accessibilityLabel={_(
one: 'Reply (# reply)', msg`Reply (${plural(post.replyCount || 0, {
other: 'Reply (# replies)', one: '# reply',
})} other: '# replies',
})})`,
)}
accessibilityHint="" accessibilityHint=""
hitSlop={POST_CTRL_HITSLOP}> hitSlop={POST_CTRL_HITSLOP}>
<Bubble <Bubble
@@ -298,14 +300,18 @@ let PostCtrls = ({
accessibilityRole="button" accessibilityRole="button"
accessibilityLabel={ accessibilityLabel={
post.viewer?.like post.viewer?.like
? plural(post.likeCount || 0, { ? _(
one: 'Unlike (# like)', msg`Unlike (${plural(post.likeCount || 0, {
other: 'Unlike (# likes)', one: '# like',
}) other: '# likes',
: plural(post.likeCount || 0, { })})`,
one: 'Like (# like)', )
other: 'Like (# likes)', : _(
}) msg`Like (${plural(post.likeCount || 0, {
one: '# like',
other: '# likes',
})})`,
)
} }
accessibilityHint="" accessibilityHint=""
hitSlop={POST_CTRL_HITSLOP}> hitSlop={POST_CTRL_HITSLOP}>
+14 -4
View File
@@ -62,11 +62,21 @@ let RepostButton = ({
{padding: 5}, {padding: 5},
]} ]}
hoverStyle={t.atoms.bg_contrast_25} hoverStyle={t.atoms.bg_contrast_25}
label={`${ label={
isReposted isReposted
? _(msg`Undo repost`) ? _(
: _(msg({message: 'Repost', context: 'action'})) msg`Undo repost (${plural(repostCount || 0, {
} (${plural(repostCount || 0, {one: '# repost', other: '# reposts'})})`} one: '# repost',
other: '# reposts',
})})`,
)
: _(
msg`Repost (${plural(repostCount || 0, {
one: '# repost',
other: '# reposts',
})})`,
)
}
shape="round" shape="round"
variant="ghost" variant="ghost"
color="secondary" color="secondary"
+3 -5
View File
@@ -587,11 +587,9 @@ function AboutSection({
label={_(msg`View users who like this feed`)} label={_(msg`View users who like this feed`)}
to={makeCustomFeedLink(feedOwnerDid, feedRkey, 'liked-by')} to={makeCustomFeedLink(feedOwnerDid, feedRkey, 'liked-by')}
style={[t.atoms.text_contrast_medium, a.font_bold]}> style={[t.atoms.text_contrast_medium, a.font_bold]}>
<Plural <Trans>
value={likeCount} Liked by <Plural value={likeCount} one="# user" other="# users" />
one="Liked by # user" </Trans>
other="Liked by # users"
/>
</InlineLinkText> </InlineLinkText>
)} )}
</View> </View>