opencode
opencode copied to clipboard
feat(i18n): add internationalization with Korean translations
Summary
This PR adds internationalization (i18n) support to OpenCode, starting with Korean translations.
Features
-
i18n Infrastructure: Introduced
t()function for type-safe translations with placeholder support -
Locale Detection: Automatically detects system locale (
LANG,LC_ALL) with fallback to English -
Environment Variable: Support
OPENCODE_LANGenv var to override language (e.g.,OPENCODE_LANG=ko) -
Config Option: Can set language in
opencode.jsonvialanguagefield - Language Selector: Added language selection dialog accessible from command palette (Ctrl+P)
- ~200 Translation Keys: Comprehensive coverage of TUI and CLI strings
Supported Locales
| Locale | Language |
|---|---|
en |
English (default) |
ko |
Korean |
Usage
# Via environment variable
OPENCODE_LANG=ko opencode
# Or set in config
# opencode.json
{
"language": "ko"
}
Files Changed
-
src/i18n/index.ts- Core i18n infrastructure -
src/i18n/en.ts- English translations (~200 keys) -
src/i18n/ko.ts- Korean translations (~200 keys) -
src/cli/cmd/tui/component/dialog-language.tsx- Language selection dialog - Updated 45+ files to use
t()function
Screenshots
Language Selection Dialog
Users can switch languages via command palette (Ctrl+P → "Switch Language")
Korean UI
All dialogs, buttons, toasts, and messages are translated
Adding New Languages
To add a new language:
- Create
src/i18n/{locale}.ts(copy fromen.ts) - Translate all keys
- Import in
src/i18n/index.ts - Add to
translationsobject andSupportedLocaletype
Testing
- [x] Typecheck passes
- [x] English (default) works correctly
- [x] Korean translations display properly
- [x] Language switching works via dialog
- [x] Environment variable override works
- [x] System locale detection works
Breaking Changes
None. English remains the default language.
This is my first contribution to OpenCode. Feedback welcome!