Skip to content

Commit f1045d9

Browse files
committed
feat: add getTimeUnitTranslations helper
rm I18nProvider
1 parent 9963b4a commit f1045d9

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

app/[locale]/10years/_components/utils.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
import { getTranslations } from "next-intl/server"
2+
13
import { formatDate, isValidDate } from "@/lib/utils/date"
24

35
import { DEFAULT_LOCALE } from "@/lib/constants"
46

7+
import { TimeLeftLabels } from "../types"
8+
59
import type { Story } from "./types"
610

711
const parseDate = (date: string, locale = DEFAULT_LOCALE): string => {
@@ -29,3 +33,29 @@ export const parseStoryDates = (
2933
...story,
3034
date: parseDate(date, locale),
3135
}))
36+
37+
export const getTimeUnitTranslations = async (locale: string) => {
38+
const t = await getTranslations({
39+
locale,
40+
namespace: "page-10-year-anniversary",
41+
})
42+
const timeLeftLabels: TimeLeftLabels = {
43+
days: {
44+
singular: t("page-10-year-countdown-day"),
45+
plural: t("page-10-year-countdown-days"),
46+
},
47+
hours: {
48+
singular: t("page-10-year-countdown-hour"),
49+
plural: t("page-10-year-countdown-hours"),
50+
},
51+
minutes: {
52+
singular: t("page-10-year-countdown-minute"),
53+
plural: t("page-10-year-countdown-minutes"),
54+
},
55+
seconds: {
56+
singular: t("page-10-year-countdown-second"),
57+
plural: t("page-10-year-countdown-seconds"),
58+
},
59+
}
60+
return timeLeftLabels
61+
}

src/intl/en/page-10-year-anniversary.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,15 @@
4343
"page-10-year-ideas-cta": "Submit your Idea",
4444
"page-10-year-event-link": "Go to event",
4545
"page-10-year-countdown-expired": "Ethereum is 10 years old! 🚀",
46+
"page-10-year-countdown-day": "day",
4647
"page-10-year-countdown-days": "days",
48+
"page-10-year-countdown-hour": "hour",
4749
"page-10-year-countdown-hours": "hours",
50+
"page-10-year-countdown-minute": "minute",
4851
"page-10-year-countdown-minutes": "minutes",
52+
"page-10-year-countdown-second": "second",
4953
"page-10-year-countdown-seconds": "seconds",
54+
"page-10-year-banner-header": "10 years of ethereum",
5055
"page-10-year-banner-launch-text": "On July 30, 2015, at 3:44 p.m. UTC, the first block of the Ethereum blockchain came to life.",
5156
"page-10-year-banner-tagline": "Ten years down, infinity to go! 🚀",
5257
"page-10-year-banner-cta": "Join the party",

src/lib/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,3 +1049,9 @@ export type SlugPageParams = PageParams & {
10491049
slug: string[]
10501050
}
10511051

1052+
export type TimeLeftLabel = { singular: string; plural: string }
1053+
1054+
export type TimeLeftLabels = Record<
1055+
"days" | "hours" | "minutes" | "seconds",
1056+
TimeLeftLabel
1057+
>

0 commit comments

Comments
 (0)