fix: translate remaining pantry UI (print button, manager, print page)

pantry-page-header's Print button, the pantry-manager add/remove
form (item name, qty, unit, expiry badges), and the print/pantry
page (title, column headers, item count, empty state, footer) were
all hardcoded English.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Arnaud
2026-07-02 15:25:09 +02:00
parent eb424d8c04
commit 737d011c1b
5 changed files with 60 additions and 21 deletions
+10 -8
View File
@@ -2,10 +2,12 @@ import { headers } from "next/headers";
import { auth } from "@/lib/auth/server";
import { db, pantryItems, eq, asc } from "@epicure/db";
import { PrintTrigger } from "@/components/recipe/print-trigger";
import { getMessages, formatMessage } from "@/lib/i18n/server";
export default async function PantryPrintPage() {
const session = await auth.api.getSession({ headers: await headers() });
if (!session) return null;
const m = getMessages((session.user as { locale?: string }).locale);
const items = await db.query.pantryItems.findMany({
where: eq(pantryItems.userId, session.user.id),
@@ -49,18 +51,18 @@ export default async function PantryPrintPage() {
<PrintTrigger />
<h1>Pantry</h1>
<p className="subtitle">{items.length} item{items.length !== 1 ? "s" : ""}</p>
<h1>{m.pantry.title}</h1>
<p className="subtitle">{formatMessage(items.length === 1 ? m.pantry.printItemCountSingular : m.pantry.printItemCountPlural, { count: items.length })}</p>
{items.length === 0 ? (
<p style={{ color: "#888" }}>No items in pantry.</p>
<p style={{ color: "#888" }}>{m.pantry.noItems}</p>
) : (
<table>
<thead>
<tr>
<th>Item</th>
<th>Quantity</th>
<th>Expires</th>
<th>{m.pantry.colItem}</th>
<th>{m.pantry.colQuantity}</th>
<th>{m.pantry.colExpires}</th>
</tr>
</thead>
<tbody>
@@ -75,7 +77,7 @@ export default async function PantryPrintPage() {
<td className={expiryClass}>
{exp
? daysLeft !== null && daysLeft < 0
? `Expired ${Math.abs(daysLeft)}d ago`
? formatMessage(m.pantry.expiredDaysAgo, { days: Math.abs(daysLeft) })
: exp.toLocaleDateString("en", { month: "short", day: "numeric", year: "numeric" })
: "—"}
</td>
@@ -86,7 +88,7 @@ export default async function PantryPrintPage() {
</table>
)}
<footer>Printed from Epicure</footer>
<footer>{m.print.footer}</footer>
</>
);
}