fix: translate dietary tags, recipe tags form, edit title, nutrition bar (v0.27.2)

These were hardcoded English strings ignoring app locale:
DietaryTagPicker, the recipe tag-input label/placeholder/help/aria-label,
the Edit recipe page heading, and WeeklyNutritionBar's labels/messages.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Arnaud
2026-07-14 13:20:38 +02:00
parent 8ef97da2c2
commit 1237330a0c
10 changed files with 62 additions and 24 deletions
@@ -1,5 +1,7 @@
"use client";
import { useTranslations } from "next-intl";
type DietaryTags = {
vegan?: boolean;
vegetarian?: boolean;
@@ -10,15 +12,7 @@ type DietaryTags = {
kosher?: boolean;
};
const TAG_LABELS: Record<keyof DietaryTags, string> = {
vegan: "Vegan",
vegetarian: "Vegetarian",
glutenFree: "Gluten-free",
dairyFree: "Dairy-free",
nutFree: "Nut-free",
halal: "Halal",
kosher: "Kosher",
};
const TAG_KEYS: (keyof DietaryTags)[] = ["vegan", "vegetarian", "glutenFree", "dairyFree", "nutFree", "halal", "kosher"];
export function DietaryTagPicker({
value,
@@ -27,9 +21,11 @@ export function DietaryTagPicker({
value: DietaryTags;
onChange: (tags: DietaryTags) => void;
}) {
const t = useTranslations("recipe.dietary");
return (
<div className="flex flex-wrap gap-2">
{(Object.entries(TAG_LABELS) as [keyof DietaryTags, string][]).map(([key, label]) => {
{TAG_KEYS.map((key) => {
const label = t(key);
const active = !!value[key];
return (
<button
+4 -4
View File
@@ -431,7 +431,7 @@ export function RecipeForm({ recipeId, defaultValues }: RecipeFormProps) {
{/* Tags */}
<div className="space-y-2">
<Label>Tags</Label>
<Label>{t("tags")}</Label>
<div
className="flex flex-wrap gap-1.5 min-h-[36px] rounded-lg border border-input bg-transparent px-2.5 py-1.5 cursor-text focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50"
onClick={() => tagInputRef.current?.focus()}
@@ -447,7 +447,7 @@ export function RecipeForm({ recipeId, defaultValues }: RecipeFormProps) {
type="button"
onClick={(e) => { e.stopPropagation(); removeTag(tag); }}
className="hover:text-foreground transition-colors"
aria-label={`Remove tag ${tag}`}
aria-label={t("removeTagAriaLabel", { tag })}
>
<X className="h-2.5 w-2.5" />
</button>
@@ -460,12 +460,12 @@ export function RecipeForm({ recipeId, defaultValues }: RecipeFormProps) {
onChange={(e) => setTagInput(e.target.value)}
onKeyDown={handleTagKeyDown}
onBlur={() => { if (tagInput.trim()) addTag(tagInput); }}
placeholder={tags.length === 0 ? "Add tags… (press Enter)" : ""}
placeholder={tags.length === 0 ? t("tagsPlaceholder") : ""}
className="flex-1 min-w-[120px] bg-transparent text-sm outline-none placeholder:text-muted-foreground"
/>
)}
</div>
<p className="text-xs text-muted-foreground">Press Enter to add · Backspace to remove last · max 20 tags</p>
<p className="text-xs text-muted-foreground">{t("tagsHelp")}</p>
</div>
</div>