Skip to content

feat: Add --language parameter for localized content generation#142

Merged
Lum1104 merged 5 commits into
Lum1104:mainfrom
zhushen12580:feature/language-parameter
May 12, 2026
Merged

feat: Add --language parameter for localized content generation#142
Lum1104 merged 5 commits into
Lum1104:mainfrom
zhushen12580:feature/language-parameter

Conversation

@zhushen12580
Copy link
Copy Markdown
Contributor

Summary

This PR implements the --language parameter for the /understand command, allowing users to generate knowledge graph content in their preferred language.

Closes #141


Changes

Skill Definition (SKILL.md)

  • Updated argument-hint to include --language <lang>
  • Added --language documentation in Options section
  • Added Phase 0 step 3.6 for language configuration:
    • Language code normalization (friendly names → ISO codes)
    • Config persistence in .understand-anything/config.json
    • $LANGUAGE_DIRECTIVE template for agent dispatch

Agent Dispatch Modifications

Injected $LANGUAGE_DIRECTIVE into dispatch prompts for all content-generating phases:

  • Phase 1 (SCAN) - project-scanner
  • Phase 2 (ANALYZE) - file-analyzer
  • Phase 4 (ARCHITECTURE) - architecture-analyzer
  • Phase 5 (TOUR) - tour-builder

Agent Definition Updates

Added language directive handling instructions in:

  • project-scanner.md - affects description field
  • file-analyzer.md - affects summary, tags, languageNotes
  • architecture-analyzer.md - affects layer name, description
  • tour-builder.md - affects title, description, languageLesson

Locale Template Files

Created locales/ directory with language-specific guidance:

File Language
en.md English (default)
zh.md Chinese Simplified
zh-TW.md Chinese Traditional
ja.md Japanese
ko.md Korean

Each locale file provides guidance for:

  • Tag naming conventions (localized vs English technical terms)
  • Summary writing style
  • Technical term handling (when to keep English)
  • Layer name translations

Usage Examples

# Generate in Chinese
/understand --language zh

# Generate in Japanese
/understand --language ja

# Combine with other options
/understand --language ko --full

# Use friendly name (auto-normalized to ISO code)
/understand --language chinese

Testing

  • All packages build successfully (pnpm build)
  • No TypeScript compilation errors
  • New locale files validated for syntax

Implementation Notes

  • Config persistence: Language preference is stored in .understand-anything/config.json for consistency across incremental updates
  • Fallback behavior: If no --language specified, uses stored config or defaults to en
  • Locale injection: If $OUTPUT_LANGUAGE is NOT en, locale guidance file is injected into architecture-analyzer prompt (Phase 4 step 4)
  • Technical terms: Locale files recommend keeping certain terms in English (middleware, hook, barrel, ORM, REST API, etc.)

Adds --language parameter to /understand command to generate knowledge
graph content in user-specified language.

Changes:
- Update argument-hint and Options documentation in SKILL.md
- Add language parsing logic in Phase 0 (language normalization,
  config persistence, LANGUAGE_DIRECTIVE template)
- Inject language directive into agent dispatch prompts for all
  content-generating phases (Phase 1-5)
- Add language directive handling instructions in agent definitions
- Create locales/ directory with template files for:
  - English (en.md) - default
  - Chinese Simplified (zh.md)
  - Chinese Traditional (zh-TW.md)
  - Japanese (ja.md)
  - Korean (ko.md)

Locale files provide language-specific guidance for:
- Tag naming conventions
- Summary writing style
- Technical term handling
- Layer name translations

Closes Lum1104#141
@Lum1104
Copy link
Copy Markdown
Owner

Lum1104 commented May 11, 2026

Sounds good. We also discuss this feature here. Really useful!

@zhushen12580
Copy link
Copy Markdown
Contributor Author

Sounds good. We also discuss this feature here. Really useful!
以下是测试效果,主体内容是使用者指定的语言,需要我将Dashboard界面也改成用户指定的语言吗

image image

- Add outputLanguage field to ProjectConfig type
- Create /config.json endpoint in vite.config.ts
- Build locale files for 5 languages (en, zh, zh-TW, ja, ko)
- Add I18nProvider context and useI18n hook
- Update 5 components (ProjectOverview, NodeInfo, FileExplorer, FilterPanel, PersonaSelector)
- Dashboard reads language from config.json and displays localized UI

All tests passed:
- Core: 670 tests
- Dashboard: 42 tests
@Lum1104
Copy link
Copy Markdown
Owner

Lum1104 commented May 11, 2026

Awesome! @codex review this~

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 752fe59e0c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread understand-anything-plugin/packages/dashboard/src/App.tsx Outdated
Comment thread understand-anything-plugin/skills/understand/SKILL.md Outdated
…onfig

P1: MobileLayout was missing I18nProvider wrapper, causing useI18n
    to throw error on mobile devices. Now both desktop and mobile
    layouts are wrapped with I18nProvider.

P2: SKILL.md used 'language' key but Dashboard reads 'outputLanguage'.
    Fixed config.json key name to match ProjectConfig type definition.

All tests passed:
- Core: 670 tests
- Dashboard: 42 tests
@zhushen12580
Copy link
Copy Markdown
Contributor Author

Awesome! @codex review this~

最新提交的i18n for UI text还存在问题,🤭正在修复。

@chatgpt-codex-connector
Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@zhushen12580
Copy link
Copy Markdown
Contributor Author

zhushen12580 commented May 11, 2026

搞定!Dashboard界面语言跟随knowledge graph content的语言,目前支持简体中文、英文、韩文、日文、繁体中文。
image
审查一下 @codex

@Lum1104
Copy link
Copy Markdown
Owner

Lum1104 commented May 12, 2026

@codex review this

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a3ec91bf39

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread understand-anything-plugin/pnpm-workspace.yaml Outdated
Comment thread understand-anything-plugin/packages/dashboard/src/App.tsx Outdated
- Remove invalid allowBuilds from pnpm-workspace.yaml (use onlyBuiltDependencies in root package.json)
- Use data-testid for search input selector (fixes / keyboard shortcut for non-English locales)
@Lum1104 Lum1104 merged commit 4c6f7c3 into Lum1104:main May 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Add --language parameter to /understand command for localized content generation

2 participants