feat(i18n): translate hardcoded strings across print, public recipe, and recipe management UI
Wires dozens of components and server pages to next-intl instead of hardcoded English text, and adds a lightweight getMessages/formatMessage helper for server components (print pages, public recipe page, cook metadata) since next-intl/server isn't wired into this app's routing. Backfills missing en/fr message keys that existing code already referenced but fr.json lacked.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import { useState, useEffect, useCallback } from "react";
|
||||
import { MessageCircle, Reply, Trash2 } from "lucide-react";
|
||||
import { toast } from "sonner";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
|
||||
@@ -97,6 +98,7 @@ function CommentItem({
|
||||
}) {
|
||||
const [showReply, setShowReply] = useState(false);
|
||||
const isOwn = comment.userId === currentUserId;
|
||||
const t = useTranslations("social");
|
||||
|
||||
async function deleteComment() {
|
||||
const res = await fetch(`/api/v1/comments/${comment.id}`, { method: "DELETE" });
|
||||
@@ -141,7 +143,7 @@ function CommentItem({
|
||||
recipeId={recipeId}
|
||||
parentId={comment.id}
|
||||
onSubmit={() => { setShowReply(false); onRefresh(); }}
|
||||
placeholder="Reply…"
|
||||
placeholder={t("replyPlaceholder")}
|
||||
onCancel={() => setShowReply(false)}
|
||||
/>
|
||||
)}
|
||||
@@ -191,6 +193,7 @@ export function CommentsSection({
|
||||
}) {
|
||||
const [comments, setComments] = useState<Comment[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const t = useTranslations("social");
|
||||
|
||||
const load = useCallback(async () => {
|
||||
const res = await fetch(`/api/v1/recipes/${recipeId}/comments`);
|
||||
@@ -212,7 +215,7 @@ export function CommentsSection({
|
||||
</div>
|
||||
|
||||
{currentUserId && (
|
||||
<CommentForm recipeId={recipeId} onSubmit={load} placeholder="Share your thoughts…" />
|
||||
<CommentForm recipeId={recipeId} onSubmit={load} placeholder={t("commentPlaceholder")} />
|
||||
)}
|
||||
|
||||
{loading ? (
|
||||
|
||||
Reference in New Issue
Block a user