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

@@ -637,6 +637,47 @@ def fill_default_translations(db: Session = Depends(get_db)):
return {"message": f"Updated {updated_count} translations with default values"}
@router.post("/seed-all-defaults")
def seed_all_default_translations(db: Session = Depends(get_db)):
"""
Seed ALL translations from the DEFAULT_TRANSLATIONS dictionary into the database.
This pre-populates translations for all known terms, not just those in the cars table.
"""
added_count = 0
skipped_count = 0
for category, terms in DEFAULT_TRANSLATIONS.items():
for korean_text, translations in terms.items():
# Check if already exists
existing = db.query(Translation).filter(
Translation.source_text == korean_text,
Translation.category == category
).first()
if existing:
skipped_count += 1
continue
trans = Translation(
source_text=korean_text,
category=category,
text_en=translations.get("en", korean_text),
text_mn=translations.get("mn", korean_text),
text_ru=translations.get("ru", korean_text)
)
db.add(trans)
added_count += 1
db.commit()
return {
"message": f"Seeded {added_count} translations from default dictionary (skipped {skipped_count} existing)",
"added": added_count,
"skipped": skipped_count,
"categories": list(DEFAULT_TRANSLATIONS.keys())
}
# AI Auto-Translation Service
import httpx
import json