Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sawyerh committed Dec 8, 2023
1 parent 6e759ea commit 2672191
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
22 changes: 13 additions & 9 deletions app/src/app/[locale]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ import { Metadata } from "next";
import { useTranslations } from "next-intl";
import { getTranslations } from "next-intl/server";

export async function generateMetadata({
params: { locale },
}: {
params: { locale: string };
}): Promise<Metadata> {
const t = await getTranslations({ locale, namespace: "home" });

return {
title: t("title"),
interface RouteParams {
locale: string;
}

export async function generateMetadata({ params }: { params: RouteParams }) {
const t = await getTranslations({ locale: params.locale });
const meta: Metadata = {
title: t("home.title"),
};

return meta;
}

export default function Page() {
Expand All @@ -21,6 +22,8 @@ export default function Page() {
return (
<>
<h1>{t("title")}</h1>

{/* Demonstration of more complex translated strings, with safe-listed links HTML elements */}
<p className="usa-intro">
{t.rich("intro", {
LinkToNextJs: (content) => (
Expand All @@ -35,6 +38,7 @@ export default function Page() {
})}

<p>
{/* Demonstration of formatters */}
{t("formatting", {
amount: 1234,
isoDate: new Date("2023-11-29T23:30:00.000Z"),
Expand Down
5 changes: 4 additions & 1 deletion app/src/types/i18n.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Use type safe message keys with `next-intl`
/**
* @file Setup type safe message keys with `next-intl`
* @see https://next-intl-docs.vercel.app/docs/workflows/typescript
*/
type Messages = typeof import("src/i18n/messages/en-US").messages;
type IntlMessages = Messages;

0 comments on commit 2672191

Please sign in to comment.