Skip to content

feat(i18n): 添加多语言切换功能,支持中英文#428

Merged
666ghj merged 33 commits into666ghj:mainfrom
Ghostubborn:feat/i18n
Apr 2, 2026
Merged

feat(i18n): 添加多语言切换功能,支持中英文#428
666ghj merged 33 commits into666ghj:mainfrom
Ghostubborn:feat/i18n

Conversation

@Ghostubborn
Copy link
Copy Markdown
Contributor

概述

  • 基于 vue-i18n(前端)和共享翻译文件(后端)实现多语言切换
  • 初始支持中文(默认)和英文,已预注册 7 种语言供社区贡献
  • 629 个翻译 key,覆盖 UI 文本、API 响应、SSE 进度消息、LLM prompt 和控制台日志
  • 社区贡献者添加新语种只需新建一个 JSON 文件,无需改任何代码

改动内容

  • 新增locales/ 目录,包含 languages.jsonzh.jsonen.json
  • 前端:vue-i18n 配置、语言切换组件、所有硬编码中文替换为 $t() 调用、英文版布局 CSS 适配
  • 后端locale.py 翻译工具、API/SSE/logger 消息使用 t()、LLM prompt 注入语言指令、后台线程 locale 传递
  • Prompt:硬编码语言指令改为动态 get_language_instruction(),技术标识符(PascalCase、枚举值)不受语言切换影响

…n calls

Replace all user-visible hardcoded Chinese strings in 7 component files
with $t() / t() calls using vue-i18n:

- Step1GraphBuild: ontology generation, graph build, status badges
- Step2EnvSetup: simulation setup, agent personas, platform config,
  time config, initial activation, modal profile details
- Step3Simulation: report generation button
- Step4Report: section loading text, interaction button
- Step5Interaction: chat interface, survey UI, tool descriptions,
  error messages, agent selection
- GraphPanel: graph status hints, loading states, tooltips
- HistoryDatabase: history cards, modal, replay buttons

Added missing translation keys to both zh.json and en.json locale files.
Added useI18n imports to components that need script-level translations.
…mpts

- oasis_profile_generator: replace hardcoded "使用中文" with dynamic get_language_instruction()
- ontology_generator: remove hardcoded "(中文)" from schema annotation
- report_agent: replace Chinese-specific language consistency rules with language-neutral ones
- zep_tools: dynamically select quote style based on locale
…ge setting

The language instruction was causing LLM to change entity/relation naming
conventions. Now explicitly enforce PascalCase/UPPER_SNAKE_CASE for technical
identifiers while only applying language preference to description fields.
…fig generator

Ensure poster_type stays PascalCase English and stance stays English enum
values regardless of language setting. Only natural language fields follow
the user's language preference.
Background threads (graph building, simulation prep, report generation,
profile generation) now inherit the requesting user's locale preference.
Previously these fell back to 'zh' because Flask request context was
unavailable in spawned threads.
… generator

Also update simulation prompts to be locale-neutral for timezone/schedule.
Covers ReportLogger message fields and logger messages shown via ConsoleLogger.
…ools.py

These are shown to users via ConsoleLogger in the report page.
- Use sans-serif font for English titles, descriptions and navbar
- Shorten English hero text to avoid overflow
- Fix :global() scoped CSS issue that was setting root font-size to 3.5rem
- Use separate unscoped style block for html[lang] selectors
Only UI display text is replaced. Regex parsing patterns are kept as-is
since they match the backend output format.
…itle

- Add sans-serif font for English left-pane (status, workflow sections)
- Shorten English workflow step descriptions
- Reduce English report title font-size from 36px to 28px
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. enhancement New feature or request labels Apr 1, 2026
@666ghj
Copy link
Copy Markdown
Owner

666ghj commented Apr 2, 2026

PR-428-审计报告.html

@Ghostubborn
Copy link
Copy Markdown
Contributor Author

PR-428-审计报告.html

问题1、2、6已修复,问题3不是问题,目前项目未用到SSE

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.

2 participants