[PR #6776] feat(i18n): add internationalization with Korean translations #12101

Open
opened 2026-02-16 18:17:02 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/6776

State: open
Merged: No


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

  • Typecheck passes
  • English (default) works correctly
  • Korean translations display properly
  • Language switching works via dialog
  • Environment variable override works
  • System locale detection works

Breaking Changes

None. English remains the default language.


This is my first contribution to OpenCode. Feedback welcome!

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6776 **State:** open **Merged:** No --- ## 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 ```bash # 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!
yindo added the pull-request label 2026-02-16 18:17:02 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12101