Skip to content

feat: add i18n support for Chinese and English CLI#1

Open
ironfrancis wants to merge 1 commit into
yzddp:masterfrom
ironfrancis:feature/i18n-chinese-support
Open

feat: add i18n support for Chinese and English CLI#1
ironfrancis wants to merge 1 commit into
yzddp:masterfrom
ironfrancis:feature/i18n-chinese-support

Conversation

@ironfrancis
Copy link
Copy Markdown

Summary

Add internationalization (i18n) support for HarnessCode CLI, allowing users to switch between English and Chinese interface while keeping source code comments and logs in English.

Features

  • hc config language zh - Switch to Chinese interface
  • hc config language en - Switch to English interface
  • HARNESSCODE_LANGUAGE=zh hc - Use environment variable for language

Changes

New Files

  • src/harnesscode/utils/i18n.py - i18n module with translation loader
  • src/harnesscode/locales/en.json - English translations
  • src/harnesscode/locales/zh.json - Chinese translations

Modified Files

  • src/harnesscode/cli.py - Added translation support and hc config command
  • src/harnesscode/installer.py - Updated user-facing messages to use translations
  • src/harnesscode/infinite_dev.py - Updated interactive prompts (model selection, branch selection)
  • src/harnesscode/restore_config.py - Updated restore messages
  • src/harnesscode/utils/config.py - Added get_language_from_config() function
  • README.md - Added language configuration documentation
  • README_CN.md - Added language configuration documentation

Design Principles

  • Source code comments and logs remain in English
  • Only user-facing prompts support translation
  • Default language is English (backward compatible)
  • Centralized translation management in JSON files
  • Easy to add more languages in the future

Testing

Tested the following scenarios:

  • English help display (hc, hc --help)
  • Chinese help display (HARNESSCODE_LANGUAGE=zh hc)
  • Configuration view (hc config)
  • Language switching via config and environment variable

Usage

# View current configuration
hc config

# Switch to Chinese
hc config language zh

# Switch to English
hc config language en

# Or use environment variable
HARNESSCODE_LANGUAGE=zh hc

- Add i18n module with translation support
- Create English and Chinese locale files
- Add language configuration via hc config command
- Support HARNESSCODE_LANGUAGE environment variable
- Update all user-facing CLI messages to use translations
- Update README documentation with language configuration
- Keep source code comments and logs in English

Features:
- hc config language zh  # Switch to Chinese
- hc config language en  # Switch to English
- HARNESSCODE_LANGUAGE=zh hc  # Use environment variable

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
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.

1 participant