Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve plural marks #3948

Closed
wants to merge 13 commits into from
8 changes: 5 additions & 3 deletions src/components/LabelingServiceCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function Description({value, handle}: {value?: string; handle: string}) {
)
}

export function LikeCount({count}: {count: number}) {
export function LikeCount({likeCount}: {likeCount: number}) {
const t = useTheme()
return (
<Text
Expand All @@ -68,7 +68,9 @@ export function LikeCount({count}: {count: number}) {
t.atoms.text_contrast_medium,
{fontWeight: '500'},
]}>
<Plural value={count} one="Liked by # user" other="Liked by # users" />
<Trans>
Liked by <Plural value={likeCount} one="# user" other="# users" />
</Trans>
</Text>
)
}
Expand Down Expand Up @@ -113,7 +115,7 @@ export function Default({
value={labeler.creator.description}
handle={labeler.creator.handle}
/>
{labeler.likeCount ? <LikeCount count={labeler.likeCount} /> : null}
{labeler.likeCount ? <LikeCount likeCount={labeler.likeCount} /> : null}
</Content>
</Outer>
)
Expand Down
28 changes: 17 additions & 11 deletions src/components/moderation/LabelsOnMe.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import {StyleProp, View, ViewStyle} from 'react-native'
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 {useSession} from '#/state/session'
Expand Down Expand Up @@ -52,17 +52,23 @@ export function LabelsOnMe({
<ButtonIcon position="left" icon={CircleInfo} />
<ButtonText style={[a.leading_snug]}>
{isAccount ? (
<Plural
value={labels.length}
one="# label has been placed on this account"
other="# labels have been placed on this account"
/>
<Trans>
<Plural
value={labels.length}
one="# label has"
other="# labels have"
/>{' '}
been placed on this account
</Trans>
) : (
<Plural
value={labels.length}
one="# label has been placed on this content"
other="# labels have been placed on this content"
/>
<Trans>
<Plural
value={labels.length}
one="# label has"
other="# labels have"
/>{' '}
been placed on this content
</Trans>
)}
</ButtonText>
</Button>
Expand Down
23 changes: 14 additions & 9 deletions src/screens/Profile/Header/ProfileHeaderLabeler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,12 @@ let ProfileHeaderLabeler = ({
},
}}
size="tiny"
label={plural(likeCount, {
one: 'Liked by # user',
other: 'Liked by # users',
})}>
label={_(
msg`Liked by ${plural(likeCount, {
one: '# user',
other: '# users',
})}`,
)}>
{({hovered, focused, pressed}) => (
<Text
style={[
Expand All @@ -296,11 +298,14 @@ let ProfileHeaderLabeler = ({
(hovered || focused || pressed) &&
t.atoms.text_contrast_high,
]}>
<Plural
value={likeCount}
one="Liked by # user"
other="Liked by # users"
/>
<Trans>
Liked by{' '}
<Plural
value={likeCount}
one="# user"
other="# users"
/>
</Trans>
</Text>
)}
</Link>
Expand Down
13 changes: 8 additions & 5 deletions src/view/com/feeds/FeedSourceCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,14 @@ export function FeedSourceCardLoaded({

{showLikes && feed.type === 'feed' ? (
<Text type="sm-medium" style={[pal.text, pal.textLight]}>
<Plural
value={feed.likeCount || 0}
one="Liked by # user"
other="Liked by # users"
/>
<Trans>
Liked by{' '}
<Plural
value={feed.likeCount || 0}
one="# user"
other="# users"
/>
</Trans>
</Text>
) : null}
</Pressable>
Expand Down
30 changes: 18 additions & 12 deletions src/view/com/util/post-ctrls/PostCtrls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,12 @@ let PostCtrls = ({
requireAuth(() => onPressReply())
}
}}
accessibilityLabel={plural(post.replyCount || 0, {
one: 'Reply (# reply)',
other: 'Reply (# replies)',
})}
accessibilityLabel={_(
msg`Reply (${plural(post.replyCount || 0, {
one: '# reply',
other: '# replies',
})})`,
)}
accessibilityHint=""
hitSlop={POST_CTRL_HITSLOP}>
<Bubble
Expand Down Expand Up @@ -259,14 +261,18 @@ let PostCtrls = ({
onPress={() => requireAuth(() => onPressToggleLike())}
accessibilityLabel={
post.viewer?.like
? plural(post.likeCount || 0, {
one: 'Unlike (# like)',
other: 'Unlike (# likes)',
})
: plural(post.likeCount || 0, {
one: 'Like (# like)',
other: 'Like (# likes)',
})
? _(
msg`Unlike (${plural(post.likeCount || 0, {
one: '# like',
other: '# likes',
})})`,
)
: _(
msg`Like (${plural(post.likeCount || 0, {
one: '# like',
other: '# likes',
})})`,
)
}
accessibilityHint=""
hitSlop={POST_CTRL_HITSLOP}>
Expand Down
18 changes: 14 additions & 4 deletions src/view/com/util/post-ctrls/RepostButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,21 @@ let RepostButton = ({
{padding: 5},
]}
hoverStyle={t.atoms.bg_contrast_25}
label={`${
label={
isReposted
? _(msg`Undo repost`)
: _(msg({message: 'Repost', context: 'action'}))
} (${plural(repostCount || 0, {one: '# repost', other: '# reposts'})})`}
? _(
msg`Undo repost (${plural(repostCount || 0, {
one: '# repost',
other: '# reposts',
})})`,
)
: _(
msg`Repost (${plural(repostCount || 0, {
one: '# repost',
other: '# reposts',
})})`,
)
}
shape="round"
variant="ghost"
color="secondary"
Expand Down
8 changes: 3 additions & 5 deletions src/view/screens/ProfileFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -587,11 +587,9 @@ function AboutSection({
label={_(msg`View users who like this feed`)}
to={makeCustomFeedLink(feedOwnerDid, feedRkey, 'liked-by')}
style={[t.atoms.text_contrast_medium, a.font_bold]}>
<Plural
value={likeCount}
one="Liked by # user"
other="Liked by # users"
/>
<Trans>
Liked by <Plural value={likeCount} one="# user" other="# users" />
</Trans>
</InlineLinkText>
)}
</View>
Expand Down
Loading