Skip to content

Commit 91bd98d

Browse files
committed
locale wip
1 parent 26117c8 commit 91bd98d

3 files changed

Lines changed: 50 additions & 14 deletions

File tree

src/app/[locale]/layout.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@ import { Toaster } from "@/components/ui/toaster";
55

66
async function getMessages(locale: string) {
77
try {
8-
return (await import(`@/messages/${locale}.json`)).default;
8+
const messages = await import(`@/messages/${locale}.json`);
9+
return messages.default;
910
} catch (error) {
1011
console.error('Error loading messages:', error);
11-
return {}; // Fallback to empty messages rather than notFound()
12+
notFound();
1213
}
1314
}
1415

1516
export default async function LocaleLayout({
1617
children,
17-
params: { locale }
18+
params,
1819
}: {
1920
children: React.ReactNode;
2021
params: { locale: string };
2122
}) {
23+
const { locale } = await params;
2224
const messages = await getMessages(locale);
2325

2426
return (
@@ -32,4 +34,11 @@ export default async function LocaleLayout({
3234
</div>
3335
</NextIntlClientProvider>
3436
);
37+
}
38+
39+
export function generateStaticParams() {
40+
return [
41+
{ locale: 'en' },
42+
{ locale: 'es' }
43+
];
3544
}

src/app/layout.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ import './globals.css';
44

55
const geistSans = GeistSans;
66

7-
export const metadata: Metadata = {
8-
title: 'Mystic Guide',
9-
description: 'Your personal Tarot reading companion.',
10-
};
7+
// Make the metadata generation async and use generateMetadata instead
8+
export async function generateMetadata(): Promise<Metadata> {
9+
return {
10+
title: 'Mystic Guide',
11+
description: 'Your personal Tarot reading companion.',
12+
};
13+
}
1114

12-
export default function RootLayout({
13-
children,
14-
}: {
15-
children: React.ReactNode;
16-
}) {
17-
return (
15+
export default async function RootLayout({children, params }: { children: React.ReactNode; params: Promise<{ locale: string }> }) {
16+
const { locale } = await params;
17+
return (
1818
<html>
1919
<body className={`${geistSans.className} font-sans`}>
2020
{children}
2121
</body>
2222
</html>
2323
);
24-
}
24+
}

src/messages/fr.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"app": {
3+
"title": "Mystic Guide",
4+
"description": "Your personal Tarot reading companion",
5+
"copyright": "© {year} Mystic Guide. All rights reserved."
6+
},
7+
"spreads": {
8+
"single": {
9+
"name": "Single Card Draw",
10+
"description": "Quick insight or guidance on a specific question or general theme for the day."
11+
},
12+
"three-card": {
13+
"name": "Three-Card Spread",
14+
"description": "A versatile spread for exploring past, present, and future, or a situation, action, and outcome."
15+
}
16+
},
17+
"actions": {
18+
"startOver": "Start Over",
19+
"drawCard": "Draw Card ({count} left)",
20+
"getReading": "Get Your Reading"
21+
},
22+
"cards": {
23+
"drawFor": "Draw Cards for: {spreadName}",
24+
"nextCard": "Next card for: {position}",
25+
"drawCount": "Draw {count} {count, plural, one {card} other {cards}}."
26+
}
27+
}

0 commit comments

Comments
 (0)