Skip to content

feat(i18n): Backend locale support for LLM-generated content#245

Open
pjhoberman wants to merge 5 commits into666ghj:mainfrom
pjhoberman:feat/backend-i18n
Open

feat(i18n): Backend locale support for LLM-generated content#245
pjhoberman wants to merge 5 commits into666ghj:mainfrom
pjhoberman:feat/backend-i18n

Conversation

@pjhoberman
Copy link

@pjhoberman pjhoberman commented Mar 18, 2026

Summary

Extends the frontend i18n work from #244 to the backend — LLM-generated content (agent profiles, simulation configs, prediction reports) and all progress/status messages now respect the user's language preference.

Depends on: #244 (frontend i18n with vue-i18n)

How it works

  1. Frontend attaches Accept-Language header to every API request (via axios interceptor)
  2. Backend API endpoints capture the locale before spawning background threads
  3. Locale is passed through the entire call chain to all LLM prompt generators
  4. Each prompt generator selects Chinese or English prompt templates based on locale

What's translated

Area Examples
Agent profiles Bios, personas, topics generated in English by LLM
Simulation config Time/event config reasoning, progress messages
Report planning Outline titles, summaries, section content
Report progress "Planning report outline...", "Generating section...", "Report complete"
Report tool results "Active Memories", "Historical Memories", "Entities" labels
Config progress "Generating time config...", "Generating agent configs..."
Interview prompt Bilingual prefix for agent interviews

Files changed (11)

  • frontend/src/api/index.js - Attach Accept-Language header via interceptor
  • frontend/src/components/Step4Report.vue - Tool result labels via t() calls
  • frontend/src/i18n/locales/en.js - +28 new step4 keys
  • frontend/src/i18n/locales/zh-CN.js - +28 matching Chinese keys
  • backend/app/utils/i18n.py - NEW locale helpers
  • backend/app/services/oasis_profile_generator.py - Bilingual persona prompts
  • backend/app/services/report_agent.py - English prompt templates + bilingual logger/progress
  • backend/app/services/simulation_config_generator.py - Bilingual config prompts + progress labels
  • backend/app/services/simulation_manager.py - Pass locale through to generators
  • backend/app/api/simulation.py - Capture locale, bilingual interview prefix
  • backend/app/api/report.py - Capture locale at report/chat endpoints

Test plan

  • All Python imports pass
  • Backend starts without errors
  • Step 1: Ontology generated with English output
  • Step 2: Agent profiles generated in English
  • Step 2: Config reasoning labels in English
  • Step 4: Report outline and sections generated in English
  • Step 4: Tool result labels display in English
  • Step 5: Interview responses in English
  • Toggle back to Chinese preserves default behavior

Closes #117

pjhoberman and others added 3 commits March 18, 2026 19:42
Add internationalization support to the MiroFish frontend with
Chinese (zh-CN) as the default language and English (en) as an
alternative, switchable via a toggle button in the header.

Changes:
- Install vue-i18n and configure with Composition API mode
- Create zh-CN and en locale files with ~262 translation keys
- Add useLocaleToggle composable for shared language toggle logic
- Replace hardcoded Chinese strings with $t() calls across all
  14 Vue components and 7 views
- Add language toggle button to all page headers
- Persist language preference in localStorage
- Configure Vite @ path alias for clean imports

Chinese regex patterns that parse backend LLM responses are
intentionally preserved unchanged (Step4Report.vue, Step2EnvSetup.vue).

Also fixes API base URL to use window.location.hostname instead of
hardcoded localhost, enabling remote access.

Closes 666ghj#117
Closes 666ghj#182

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The Home page navbar is transparent (not dark as assumed), so the
white-on-transparent button was invisible. Use explicit light gray
background with dark text for guaranteed visibility on any background.
Also increase button size across all views for better discoverability.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Pass the user's language preference (from Accept-Language header) through
the backend to all LLM prompt generation, so agent profiles, simulation
configs, and prediction reports are generated in the user's chosen language.

Changes:
- Frontend: attach Accept-Language header to all API requests via
  axios interceptor (reads from localStorage mirofish-locale)
- Backend: new app/utils/i18n.py with locale helpers
- Profile generator: bilingual prompts for individual and group personas
- Report agent: English versions of plan, section, and chat prompts
- Simulation config generator: bilingual time/event/agent config prompts
- Interview prompt: locale-aware prefix
- API routes: capture locale before background threads, pass through
  the entire call chain

Locale flow:
  API endpoint -> captured before thread -> SimulationManager ->
  OasisProfileGenerator / SimulationConfigGenerator / ReportAgent

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. enhancement New feature or request labels Mar 18, 2026
pjhoberman and others added 2 commits March 18, 2026 21:20
Time/event/agent config progress messages and reasoning labels were
hardcoded in Chinese. Now locale-aware.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- ReportLogger: all log messages now bilingual (planning start/complete,
  section start, react thought, report complete)
- generate_report(): all progress callbacks bilingual
- Step4Report.vue: panorama/insight/interview/search display labels
  translated via $t() calls (active memories, historical memories,
  entities, expand/collapse, tabs, etc.)
- Added 28 new step4.* locale keys for tool result UI

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

### Feature Request: English Language Support

1 participant