opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat(i18n): add internationalization with Korean translations

Open mupozg823 opened this issue 2 weeks ago • 0 comments

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_LANG env var to override language (e.g., OPENCODE_LANG=ko)
  • Config Option: Can set language in opencode.json via language field
  • 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:

  1. Create src/i18n/{locale}.ts (copy from en.ts)
  2. Translate all keys
  3. Import in src/i18n/index.ts
  4. Add to translations object and SupportedLocale type

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!

mupozg823 avatar Jan 03 '26 21:01 mupozg823