Add 'Seed Defaults' button to load all predefined translations

- Add /translations/seed-all-defaults API endpoint
- Loads all DEFAULT_TRANSLATIONS (makers, models, colors, fuels, transmissions)
- Includes 100+ predefined translations (Mohave, Sonata, colors, etc.)
- Add 'Seed Defaults' button to admin translations page

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
AutonetSellCar Deploy
2026-01-03 20:53:14 +09:00
parent 2d7e144a21
commit b8cab29ed2
3 changed files with 69 additions and 0 deletions

View File

@@ -115,6 +115,18 @@ export default function TranslationsPage() {
}
};
const handleSeedAllDefaults = async () => {
try {
const result = await translationsApi.seedAllDefaults();
alert(`${result.message}\n\nCategories: ${result.categories.join(', ')}`);
loadTranslations();
loadStats();
} catch (err) {
console.error('Failed to seed defaults:', err);
alert('Failed to seed default translations');
}
};
const handleAutoTranslate = async (translation: Translation) => {
setTranslatingId(translation.id);
try {
@@ -217,9 +229,20 @@ export default function TranslationsPage() {
<div className="flex justify-between items-center mb-6">
<h1 className="text-2xl font-bold text-gray-800">Translations Management</h1>
<div className="flex gap-2">
<button
onClick={handleSeedAllDefaults}
className="bg-indigo-600 text-white px-4 py-2 rounded-lg hover:bg-indigo-700 flex items-center gap-2"
title="Load all predefined translations (makers, models, colors, fuels, etc.)"
>
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12" />
</svg>
Seed Defaults
</button>
<button
onClick={handleAutoExtract}
className="bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700 flex items-center gap-2"
title="Extract terms from cars in database"
>
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />