Skip to content

Commit 20c879e

Browse files
committed
setup /apps/{application} for translation
1 parent 9120b09 commit 20c879e

File tree

2 files changed

+42
-14
lines changed

2 files changed

+42
-14
lines changed

app/[locale]/apps/[application]/page.tsx

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { pick } from "lodash"
22
import { notFound } from "next/navigation"
3-
import { getMessages, setRequestLocale } from "next-intl/server"
3+
import {
4+
getMessages,
5+
getTranslations,
6+
setRequestLocale,
7+
} from "next-intl/server"
48

59
import { ChainName } from "@/lib/types"
610

@@ -58,6 +62,9 @@ const Page = async ({
5862
const { locale, application } = await params
5963
setRequestLocale(locale)
6064

65+
// Get translations
66+
const t = await getTranslations({ locale, namespace: "page-apps" })
67+
6168
// Get i18n messages
6269
const allMessages = await getMessages({ locale })
6370
const requiredNamespaces = getRequiredNamespacesForPage("/apps")
@@ -115,9 +122,9 @@ const Page = async ({
115122
const diffInMs = now.getTime() - date.getTime()
116123
const diffInDays = Math.floor(diffInMs / (1000 * 60 * 60 * 24))
117124

118-
if (diffInDays === 0) return "Today"
119-
if (diffInDays === 1) return "1 day ago"
120-
return `${diffInDays} days ago`
125+
if (diffInDays === 0) return t("page-apps-today")
126+
if (diffInDays === 1) return t("page-apps-one-day-ago")
127+
return t("page-apps-days-ago", { days: diffInDays })
121128
}
122129

123130
return (
@@ -194,7 +201,7 @@ const Page = async ({
194201
eventName: "visit",
195202
}}
196203
>
197-
Visit {app.name}
204+
{t("page-apps-visit-app", { appName: app.name })}
198205
</ButtonLink>
199206
<div className="flex flex-row justify-between gap-4">
200207
<div className="flex h-fit flex-row flex-wrap gap-4">
@@ -250,7 +257,9 @@ const Page = async ({
250257
{nextApp && (
251258
<LinkBox className="group flex flex-row items-center rounded-lg hover:bg-background-highlight sm:hidden">
252259
<div className="mr-2 flex flex-col text-right">
253-
<p className="text-sm text-gray-500">See next</p>
260+
<p className="text-sm text-gray-500">
261+
{t("page-apps-see-next")}
262+
</p>
254263
<p className="text-primary group-hover:text-primary-hover">
255264
{nextApp.name}
256265
</p>
@@ -275,7 +284,9 @@ const Page = async ({
275284
{nextApp && (
276285
<LinkBox className="group hidden flex-row items-center rounded-lg p-3 hover:bg-background-highlight sm:flex">
277286
<div className="mr-2 flex flex-col text-right">
278-
<p className="text-nowrap text-sm text-gray-500">See next</p>
287+
<p className="text-nowrap text-sm text-gray-500">
288+
{t("page-apps-see-next")}
289+
</p>
279290
<p className="text-primary group-hover:text-primary-hover">
280291
{nextApp.name}
281292
</p>
@@ -299,25 +310,31 @@ const Page = async ({
299310
<div className="grid grid-cols-1 grid-rows-[auto_1fr] gap-10 bg-background-highlight px-4 py-10 md:grid-cols-[minmax(0,1fr)_auto] md:px-8">
300311
<p className="max-w-3xl">{app.description}</p>
301312
<div className="flex h-fit w-full flex-col gap-4 rounded-2xl border bg-background p-8 md:row-span-2 md:w-44">
302-
<h3 className="text-lg">Info</h3>
313+
<h3 className="text-lg">{t("page-apps-info-title")}</h3>
303314
<div>
304-
<p className="text-sm text-body-medium">Founded</p>
315+
<p className="text-sm text-body-medium">
316+
{t("page-apps-info-founded")}
317+
</p>
305318
<p className="text-sm">
306319
{new Date(app.dateOfLaunch).getFullYear()}
307320
</p>
308321
</div>
309322
<div>
310-
<p className="text-sm text-body-medium">Creator</p>
323+
<p className="text-sm text-body-medium">
324+
{t("page-apps-info-creator")}
325+
</p>
311326
<p className="text-sm">{app.parentCompany}</p>
312327
</div>
313328
<div>
314-
<p className="text-sm text-body-medium">Last updated</p>
329+
<p className="text-sm text-body-medium">
330+
{t("page-apps-info-last-updated")}
331+
</p>
315332
<p className="text-sm">{getTimeAgo(app.lastUpdated)}</p>
316333
</div>
317334
</div>
318335
{app.screenshots.length > 0 && (
319336
<div className="flex flex-col gap-4">
320-
<h3 className="text-2xl">Gallery</h3>
337+
<h3 className="text-2xl">{t("page-apps-gallery-title")}</h3>
321338
<ScreenshotSwiper
322339
screenshots={app.screenshots}
323340
appName={app.name}
@@ -329,7 +346,7 @@ const Page = async ({
329346
{relatedApps.length > 0 && (
330347
<div className="flex flex-col px-4 py-10 md:px-8">
331348
<div className="flex w-full flex-col items-center gap-8 rounded-2xl bg-gradient-to-t from-blue-500/20 from-10% to-blue-500/5 to-90% p-12 px-4 md:px-8">
332-
<h2>More apps like this</h2>
349+
<h2>{t("page-apps-more-apps-like-this")}</h2>
333350
<div className="flex w-full flex-col gap-4 lg:flex-row">
334351
{relatedApps.map((relatedApp) => (
335352
<div

src/intl/en/page-apps.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,16 @@
5656
"page-apps-suggest-an-app-button": "Suggest an app",
5757
"page-apps-filter-by": "Filter by",
5858
"page-apps-filter-all": "All",
59-
"page-apps-showing": "Showing"
59+
"page-apps-showing": "Showing",
60+
"page-apps-visit-app": "Visit {appName}",
61+
"page-apps-see-next": "See next",
62+
"page-apps-info-title": "Info",
63+
"page-apps-info-founded": "Founded",
64+
"page-apps-info-creator": "Creator",
65+
"page-apps-info-last-updated": "Last updated",
66+
"page-apps-gallery-title": "Gallery",
67+
"page-apps-more-apps-like-this": "More apps like this",
68+
"page-apps-today": "Today",
69+
"page-apps-one-day-ago": "1 day ago",
70+
"page-apps-days-ago": "{days} days ago"
6071
}

0 commit comments

Comments
 (0)