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

chore: migrate plurals to lingui react macro #2896

Merged
merged 1 commit into from
May 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ClockIcon, PlusIcon, XIcon } from '@heroicons/react/outline';
import { MenuAlt2Icon, XCircleIcon } from '@heroicons/react/solid';
import { plural, t, Trans } from '@lingui/macro';
import { Plural, t, Trans } from '@lingui/macro';
import type { FC } from 'react';
import { useState } from 'react';
import { usePublicationStore } from 'src/store/publication';
Expand Down Expand Up @@ -31,11 +31,12 @@ const PollEditor: FC = () => {
outline
>
{pollConfig.length}{' '}
{plural(pollConfig.length, {
zero: 'day',
one: 'day',
other: 'days'
})}
<Plural
value={pollConfig.length}
zero="day"
one="day"
other="days"
/>
</Button>
<Modal
title={t`Poll length`}
Expand Down
13 changes: 7 additions & 6 deletions apps/web/src/components/Home/Trending.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import TrendingTagShimmer from '@components/Shared/Shimmer/TrendingTagShimmer';
import { TrendingUpIcon } from '@heroicons/react/solid';
import { Mixpanel } from '@lib/mixpanel';
import { plural, t, Trans } from '@lingui/macro';
import { Plural, t, Trans } from '@lingui/macro';
import type { TagResult } from 'lens';
import { TagSortCriteria, useTrendingQuery } from 'lens';
import nFormatter from 'lib/nFormatter';
Expand Down Expand Up @@ -61,11 +61,12 @@ const Trending: FC = () => {
<div className="font-bold">{tag?.tag}</div>
<div className="lt-text-gray-500 text-[12px]">
{nFormatter(tag?.total)}{' '}
{plural(tag?.total, {
zero: 'Publication',
one: 'Publication',
other: 'Publications'
})}
<Plural
value={tag?.total}
zero="Publication"
one="Publication"
other="Publications"
/>
</div>
</Link>
</div>
Expand Down
24 changes: 13 additions & 11 deletions apps/web/src/components/Profile/Followerings.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { UsersIcon } from '@heroicons/react/outline';
import { plural, t } from '@lingui/macro';
import { Plural, t } from '@lingui/macro';
import type { Profile } from 'lens';
import humanize from 'lib/humanize';
import type { FC } from 'react';
Expand Down Expand Up @@ -29,11 +29,12 @@ const Followerings: FC<FolloweringsProps> = ({ profile }) => {
{humanize(profile?.stats?.totalFollowing)}
</div>
<div className="lt-text-gray-500">
{plural(profile?.stats?.totalFollowers, {
zero: 'Following',
one: 'Following',
other: 'Following'
})}
<Plural
value={profile?.stats?.totalFollowing}
zero="Following"
one="Following"
other="Following"
/>
</div>
</button>
<button
Expand All @@ -46,11 +47,12 @@ const Followerings: FC<FolloweringsProps> = ({ profile }) => {
{humanize(profile?.stats?.totalFollowers)}
</div>
<div className="lt-text-gray-500">
{plural(profile?.stats?.totalFollowers, {
zero: 'Follower',
one: 'Follower',
other: 'Followers'
})}
<Plural
value={profile?.stats?.totalFollowers}
zero="Follower"
one="Follower"
other="Followers"
/>
</div>
</button>
<Modal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import errorToast from '@lib/errorToast';
import { formatTime } from '@lib/formatTime';
import getCoingeckoPrice from '@lib/getCoingeckoPrice';
import { Mixpanel } from '@lib/mixpanel';
import { plural, t, Trans } from '@lingui/macro';
import { Plural, t, Trans } from '@lingui/macro';
import { useQuery } from '@tanstack/react-query';
import { LensHub } from 'abis';
import { LENSHUB_PROXY, POLYGONSCAN_URL } from 'data/constants';
Expand Down Expand Up @@ -380,11 +380,12 @@ const CollectModule: FC<CollectModuleProps> = ({
onClick={() => setShowCollectorsModal(!showCollectorsModal)}
>
{humanize(count)}{' '}
{plural(count, {
zero: 'collector',
one: 'collector',
other: 'collectors'
})}
<Plural
value={count}
zero="collector"
one="collector"
other="collectors"
/>
</button>
<Modal
title={t`Collected by`}
Expand Down
46 changes: 25 additions & 21 deletions apps/web/src/components/Publication/PublicationStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
HeartIcon,
SwitchHorizontalIcon
} from '@heroicons/react/outline';
import { plural, t } from '@lingui/macro';
import { Plural, t } from '@lingui/macro';
import type { Publication } from 'lens';
import nFormatter from 'lib/nFormatter';
import type { FC } from 'react';
Expand Down Expand Up @@ -47,11 +47,12 @@ const PublicationStats: FC<PublicationStatsProps> = ({ publication }) => {
<b className="text-black dark:text-white">
{nFormatter(commentsCount)}
</b>{' '}
{plural(commentsCount, {
zero: 'Comment',
one: 'Comment',
other: 'Comments'
})}
<Plural
value={commentsCount}
zero="Comment"
one="Comment"
other="Comments"
/>
</span>
<button
type="button"
Expand All @@ -61,11 +62,12 @@ const PublicationStats: FC<PublicationStatsProps> = ({ publication }) => {
<b className="text-black dark:text-white">
{nFormatter(mirrorCount)}
</b>{' '}
{plural(mirrorCount, {
zero: 'Mirror',
one: 'Mirror',
other: 'Mirrors'
})}
<Plural
value={mirrorCount}
zero="Mirror"
one="Mirror"
other="Mirrors"
/>
</button>
<Modal
title={t`Mirrored by`}
Expand All @@ -87,11 +89,12 @@ const PublicationStats: FC<PublicationStatsProps> = ({ publication }) => {
<b className="text-black dark:text-white">
{nFormatter(reactionCount)}
</b>{' '}
{plural(reactionCount, {
zero: 'Like',
one: 'Like',
other: 'Likes'
})}
<Plural
value={reactionCount}
zero="Like"
one="Like"
other="Likes"
/>
</button>
<Modal
title={t`Liked by`}
Expand All @@ -113,11 +116,12 @@ const PublicationStats: FC<PublicationStatsProps> = ({ publication }) => {
<b className="text-black dark:text-white">
{nFormatter(collectCount)}
</b>{' '}
{plural(collectCount, {
zero: 'Collect',
one: 'Collect',
other: 'Collects'
})}
<Plural
value={collectCount}
zero="Collect"
one="Collect"
other="Collects"
/>
</button>
<Modal
title={t`Collected by`}
Expand Down
13 changes: 7 additions & 6 deletions apps/web/src/components/Shared/Snapshot/Choices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { CheckCircleIcon as CheckCircleIconOutline } from '@heroicons/react/outl
import { CheckCircleIcon, MenuAlt2Icon } from '@heroicons/react/solid';
import { getTimetoNow } from '@lib/formatTime';
import { Mixpanel } from '@lib/mixpanel';
import { plural, t, Trans } from '@lingui/macro';
import { Plural, t, Trans } from '@lingui/macro';
import type { Proposal, Vote } from '@workers/snapshot-relay';
import axios from 'axios';
import clsx from 'clsx';
Expand Down Expand Up @@ -189,11 +189,12 @@ const Choices: FC<ChoicesProps> = ({
<span>·</span>
<span>
{humanize(scores_total ?? 0)}{' '}
{plural(scores_total ?? 0, {
zero: 'Vote',
one: 'Vote',
other: 'Votes'
})}
<Plural
value={scores_total ?? 0}
zero="Vote"
one="Vote"
other="Votes"
/>
</span>
{state === 'active' && (
<>
Expand Down
24 changes: 13 additions & 11 deletions apps/web/src/components/Shared/UserPreview.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BadgeCheckIcon } from '@heroicons/react/solid';
import { plural } from '@lingui/macro';
import { Plural } from '@lingui/macro';
import Tippy from '@tippyjs/react';
import clsx from 'clsx';
import type { Profile } from 'lens';
Expand Down Expand Up @@ -123,23 +123,25 @@ const UserPreview: FC<UserPreviewProps> = ({
{nFormatter(lazyProfile?.stats?.totalFollowing)}
</div>
<div className="lt-text-gray-500 text-sm">
{plural(lazyProfile?.stats?.totalFollowers, {
zero: 'Following',
one: 'Following',
other: 'Following'
})}
<Plural
value={lazyProfile?.stats?.totalFollowing}
zero="Following"
one="Following"
other="Following"
/>
</div>
</div>
<div className="text-md flex items-center space-x-1">
<div className="text-base">
{nFormatter(lazyProfile?.stats?.totalFollowers)}
</div>
<div className="lt-text-gray-500 text-sm">
{plural(lazyProfile?.stats?.totalFollowers, {
zero: 'Follower',
one: 'Follower',
other: 'Followers'
})}
<Plural
value={lazyProfile?.stats?.totalFollowers}
zero="Follower"
one="Follower"
other="Followers"
/>
</div>
</div>
</div>
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/locales/fr/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2879,4 +2879,3 @@ msgstr ""
#: src/pages/500.tsx
msgid "We track these errors automatically, but if the problem persists feel free to contact us. In the meantime, try refreshing."
msgstr ""

1 change: 0 additions & 1 deletion apps/web/src/locales/ru/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2879,4 +2879,3 @@ msgstr "Похоже, что-то пошло не так!"
#: src/pages/500.tsx
msgid "We track these errors automatically, but if the problem persists feel free to contact us. In the meantime, try refreshing."
msgstr "Мы автоматически отслеживаем эти ошибки, но если проблема не устранена, не стесняйтесь обращаться к нам. А пока попробуйте обновить страницу."

1 change: 0 additions & 1 deletion apps/web/src/locales/ta/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2879,4 +2879,3 @@ msgstr "ஏதோ தவறாகிவிட்டது போல் தெர
#: src/pages/500.tsx
msgid "We track these errors automatically, but if the problem persists feel free to contact us. In the meantime, try refreshing."
msgstr "இந்தப் பிழைகளைத் தானாகக் கண்காணிக்கிறோம், ஆனால் சிக்கல் தொடர்ந்தால், எங்களைத் தொடர்பு கொள்ளலாம். இதற்கிடையில், புதுப்பித்து முயற்சிக்கவும்."

1 change: 0 additions & 1 deletion apps/web/src/locales/zh/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2879,4 +2879,3 @@ msgstr "系统似乎出现了故障!"
#: src/pages/500.tsx
msgid "We track these errors automatically, but if the problem persists feel free to contact us. In the meantime, try refreshing."
msgstr "我们会自动追踪这些错误,但如果问题仍然存在,请随时与我们联系。 与此同时,您可以尝试刷新页面。"

Loading