diff --git a/src/components/toys/AddToyForm.tsx b/src/components/toys/AddToyForm.tsx index 2e4ed35..ad67646 100644 --- a/src/components/toys/AddToyForm.tsx +++ b/src/components/toys/AddToyForm.tsx @@ -1,3 +1,4 @@ + 'use client'; import { useState } from 'react'; @@ -14,7 +15,21 @@ import { ToyBrick, Save, PlusCircle, Trash2 } from 'lucide-react'; import type { Toy } from '@/types'; import { useI18n, useCurrentLocale } from '@/locales/client'; -const toyCategories = ["Educational", "Vehicles", "Electronics", "Plush Toys", "Musical", "Outdoor", "Board Games", "Action Figures", "Dolls", "Puzzles", "Arts & Crafts", "Building Blocks"]; +const toyCategoryDefinitions = [ + { key: 'educational', value: 'Educational' }, + { key: 'vehicles', value: 'Vehicles' }, + { key: 'electronics', value: 'Electronics' }, + { key: 'plush_toys', value: 'Plush Toys' }, + { key: 'musical', value: 'Musical' }, + { key: 'outdoor', value: 'Outdoor' }, + { key: 'board_games', value: 'Board Games' }, + { key: 'action_figures', value: 'Action Figures' }, + { key: 'dolls', value: 'Dolls' }, + { key: 'puzzles', value: 'Puzzles' }, + { key: 'arts_crafts', value: 'Arts & Crafts' }, + { key: 'building_blocks', value: 'Building Blocks' }, +]; + const daysOfWeek = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'] as const; @@ -120,7 +135,11 @@ export default function AddToyForm({ initialData, isEditMode = false }: AddToyFo - {toyCategories.map(cat => {cat})} + {toyCategoryDefinitions.map(catDef => ( + + {t(`toy_categories.${catDef.key}` as any)} {/* Use 'as any' if TS complains about template literal type */} + + ))} @@ -193,3 +212,5 @@ export default function AddToyForm({ initialData, isEditMode = false }: AddToyFo ); } + + \ No newline at end of file diff --git a/src/locales/en.ts b/src/locales/en.ts index 95eb865..2e5a272 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -1,3 +1,4 @@ + export default { 'header.browse_toys': 'Browse Toys', 'header.login': 'Login', @@ -149,4 +150,18 @@ export default { 'owner_toys.owner_not_found': 'Owner not found or has no toys listed.', 'owner_toys.back_to_home': 'Back to Home', 'owner_toys.unknown_owner': 'Unknown Owner', + 'toy_categories.educational': 'Educational', + 'toy_categories.vehicles': 'Vehicles', + 'toy_categories.electronics': 'Electronics', + 'toy_categories.plush_toys': 'Plush Toys', + 'toy_categories.musical': 'Musical', + 'toy_categories.outdoor': 'Outdoor', + 'toy_categories.board_games': 'Board Games', + 'toy_categories.action_figures': 'Action Figures', + 'toy_categories.dolls': 'Dolls', + 'toy_categories.puzzles': 'Puzzles', + 'toy_categories.arts_crafts': 'Arts & Crafts', + 'toy_categories.building_blocks': 'Building Blocks', } as const; + + \ No newline at end of file diff --git a/src/locales/zh-TW.ts b/src/locales/zh-TW.ts index 60ade0a..8ba4edb 100644 --- a/src/locales/zh-TW.ts +++ b/src/locales/zh-TW.ts @@ -1,3 +1,4 @@ + export default { 'header.browse_toys': '瀏覽玩具', 'header.login': '登入', @@ -149,4 +150,18 @@ export default { 'owner_toys.owner_not_found': '找不到擁有者或該擁有者沒有列出任何玩具。', 'owner_toys.back_to_home': '返回首頁', 'owner_toys.unknown_owner': '未知擁有者', + 'toy_categories.educational': '教育類', + 'toy_categories.vehicles': '交通工具', + 'toy_categories.electronics': '電子玩具', + 'toy_categories.plush_toys': '絨毛玩具', + 'toy_categories.musical': '音樂玩具', + 'toy_categories.outdoor': '戶外玩具', + 'toy_categories.board_games': '桌遊', + 'toy_categories.action_figures': '動作公仔', + 'toy_categories.dolls': '娃娃', + 'toy_categories.puzzles': '拼圖', + 'toy_categories.arts_crafts': '美術勞作', + 'toy_categories.building_blocks': '積木', } as const; + + \ No newline at end of file