Skip to content

feat(i18n): complete English translation + full-stack bilingual support (en/zh-CN)#296

Open
hackingbutlegal wants to merge 11 commits into666ghj:mainfrom
hackingbutlegal:feat/localize-en
Open

feat(i18n): complete English translation + full-stack bilingual support (en/zh-CN)#296
hackingbutlegal wants to merge 11 commits into666ghj:mainfrom
hackingbutlegal:feat/localize-en

Conversation

@hackingbutlegal
Copy link
Copy Markdown

Summary

Complete English localization plus full-stack bilingual infrastructure — frontend UI, backend API messages, and LLM prompt templates — all in a single, atomic PR.

Why this PR over existing translation PRs

There are several open English translation PRs (#119, #155, #176, #189, #198, #244, #245, #290). This one is the most complete:

Capability This PR #244+#245 #189 #290 Others
Frontend vue-i18n with toggle 482 keys 262 keys Yes No Partial
Backend API message catalog 84 keys No Parameter-based No No
LLM prompt template files 35 files/locale Inline if/else Parameter-based No No
Background thread locale safety Explicit param Yes Unknown N/A No
Code comments + docstrings translated All 57 files No 43 files 15 files Varies
Single atomic PR Yes Split across 2 PRs Yes Yes Varies
Extensible to new languages Add locale dir + JSON Modify code Modify code N/A N/A

Key architectural advantage: LLM prompts are externalized into backend/app/prompts/{en,zh-CN}/*.txt template files rather than embedded in Python code with if/else branches. Adding a new language (e.g., Japanese, Korean) means adding a directory of .txt files — zero code changes.

What's included

Layer 1: Frontend (vue-i18n@9)

  • 482 translated keys per locale in frontend/src/i18n/{en,zh-CN}.json
  • Language toggle in Home and MainView navbars
  • Accept-Language header sent on all API requests via Axios interceptor
  • fallbackLocale: 'en' for graceful degradation

Layer 2: Backend API Messages

  • 84 message keys in backend/app/i18n/{en,zh-CN}.json
  • msg(key, **kwargs) helper with placeholder substitution
  • Flask before_request middleware sets g.locale from Accept-Language

Layer 3: LLM Prompt Templates

  • 35 prompt files per locale in backend/app/prompts/{en,zh-CN}/
  • load_prompt(name, locale) helper with English fallback
  • Covers: ontology generation, agent profiles, simulation config, report planning/generation/chat, Zep graph queries
  • Locale passed explicitly to background threads (not from Flask request context)

Translation (prerequisite)

  • All Chinese text in 57 files replaced with English: UI labels, code comments, docstrings, log messages, error messages

How it works

User clicks language toggle (or browser auto-detects)
  → Frontend: vue-i18n switches locale, re-renders all $t() strings
  → Axios: sends Accept-Language header on every request
  → Flask middleware: sets g.locale from header
  → API handlers: msg('key') returns localized error/status strings
  → Background threads: locale captured before spawn, passed as parameter
  → LLM services: load_prompt('name', locale) reads locale-specific .txt files
  → LLM output: generated in the user's chosen language

Test plan

  • grep for CJK characters across source files returns zero matches
  • All Python files pass python -m py_compile
  • Frontend builds with vite build
  • Frontend keys: 482 en = 482 zh-CN (zero missing)
  • Backend keys: 84 en = 84 zh-CN (zero missing)
  • Prompt files: 35 en = 35 zh-CN (zero missing)
  • Placeholder variable names match between en and zh-CN files

graffito and others added 11 commits March 22, 2026 02:04
Replace all Chinese text with English across 57 files (21 frontend,
36 backend). This makes the application usable by English speakers
and the codebase accessible to English-speaking developers.

Scope of changes:
- UI text: all Vue template labels, buttons, headings, status messages,
  placeholders, and tooltips
- Code comments and docstrings: all Python and JavaScript documentation
- LLM prompts: system prompts, user prompts, few-shot examples, and
  output formatting templates in all generator and agent services
- Log/error messages: all logger calls and API error responses
- Config files: pyproject.toml description and dependency section comments,
  requirements.txt section headers

No structural, logic, or dependency changes. All identifier names,
import paths, and code behavior are preserved.

Verified: grep for CJK characters returns zero matches across the
entire codebase. All Python files pass py_compile. Frontend builds
successfully with vite.
Full-stack i18n: vue-i18n frontend, backend message catalog,
locale-specific LLM prompt templates. 7 tasks, ~28 prompt files,
~95 API messages, ~600 frontend strings.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…t loader

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…e header

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…messages

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extracted original Chinese prompts from commit 1536a79 (pre-translation)
and wrote them to backend/app/prompts/zh-CN/ with 35 files matching
the en/ directory 1:1. All {placeholder} variable names are identical
to the English versions so .format() calls work unchanged.

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 22, 2026
@hackingbutlegal
Copy link
Copy Markdown
Author

Come on merge this thang

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.

1 participant