From e4d5b8151802517b2943756fc0d09ffa95e2c4e2 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Sat, 29 Jan 2022 18:21:37 +0100 Subject: chore: replace lingui functions with react-intl --- src/components/ProjectSummary/ProjectSummary.tsx | 68 ++++++++++++++++++++---- 1 file changed, 59 insertions(+), 9 deletions(-) (limited to 'src/components/ProjectSummary/ProjectSummary.tsx') diff --git a/src/components/ProjectSummary/ProjectSummary.tsx b/src/components/ProjectSummary/ProjectSummary.tsx index b32c11f..f2d73b6 100644 --- a/src/components/ProjectSummary/ProjectSummary.tsx +++ b/src/components/ProjectSummary/ProjectSummary.tsx @@ -1,13 +1,14 @@ import GithubIcon from '@assets/images/social-media/github.svg'; import GitlabIcon from '@assets/images/social-media/gitlab.svg'; import { config } from '@config/website'; -import { t } from '@lingui/macro'; import { ProjectMeta } from '@ts/types/app'; import { getFormattedDate } from '@utils/helpers/format'; import { slugify } from '@utils/helpers/slugify'; import useGithubApi from '@utils/hooks/useGithubApi'; +import IntlMessageFormat from 'intl-messageformat'; import Image from 'next/image'; import { useRouter } from 'next/router'; +import { useIntl } from 'react-intl'; import styles from './ProjectSummary.module.scss'; const ProjectSummary = ({ @@ -20,6 +21,7 @@ const ProjectSummary = ({ meta: ProjectMeta; }) => { const { hasCover, license, repos, technologies } = meta; + const intl = useIntl(); const router = useRouter(); const locale = router.locale ? router.locale : config.locales.defaultLocale; const { data } = useGithubApi(repos?.github ? repos.github : ''); @@ -30,7 +32,10 @@ const ProjectSummary = ({
{t`${title} @@ -39,7 +44,12 @@ const ProjectSummary = ({
{data && (
-
{t`Created on`}
+
+ {intl.formatMessage({ + defaultMessage: 'Created on:', + description: 'ProjectSummary: creation date label', + })} +
{t`Last updated on`}
+
+ {intl.formatMessage({ + defaultMessage: 'Last updated on:', + description: 'ProjectSummary: update date label', + })} +
)}
-
{t`License`}
+
+ {intl.formatMessage({ + defaultMessage: 'License:', + description: 'ProjectSummary: license label', + })} +
{license}
{technologies && (
-
{t`Technologies`}
+
+ {intl.formatMessage( + { + defaultMessage: + '{count, plural, =0 {Technologies:} one {Technology:} other {Technologies:}}', + description: 'ProjectSummary: technologies list label', + }, + { count: technologies.length } + )} +
{technologies.map((techno) => (
-
{t`Repositories`}
+
+ {intl.formatMessage( + { + defaultMessage: + '{count, plural, =0 {Repositories:} one {Repository:} other {Repositories:}}', + description: 'ProjectSummary: repositories list label', + }, + { count: Object.keys(repos).length } + )} +
{repos.github && (
-
{t`Popularity`}
+
+ {intl.formatMessage({ + defaultMessage: 'Popularity:', + description: 'ProjectSummary: popularity label', + })} +
{repos.github && (
⭐  - {t`${data.stargazers_count} stars on Github`} + {intl.formatMessage( + { + defaultMessage: + '{starsCount, plural, =0 {No stars on Github} one {# star on Github} other {# stars on Github}}', + description: 'ProjectPreview: technologies list label', + }, + { starsCount: data.stargazers_count } + )}
)} -- cgit v1.2.3