Skip to content

feat(i18n): add Korean (ko) locale - #228

Open
yangroro wants to merge 1 commit into
0xsline:mainfrom
yangroro:yangroro/i18n-korean
Open

yangroro wants to merge 1 commit into
0xsline:mainfrom
yangroro:yangroro/i18n-korean

Conversation

@yangroro

Copy link
Copy Markdown

Summary

This PR adds Korean (ko) as a UI locale. It follows the Italian locale from #117 and uses the same per-locale lazy dictionary registry.

Localization

  • Adds ko to Locale / ALL_LOCALES. A browser language of ko* now defaults to Korean, <html lang> is set to ko, and the agent's response-language prompt says Korean.
  • The top bar language button cycles 中 → EN → IT → RU → 한 and shows 한 when Korean is active.
  • Adds src/i18n/dict/ko/. It uses the same per-domain split as dict/en (audio, captions, chat, components, editor, exportPanel, fx, library, media, review, settings, timeline, topbar, transcript), and index.ts assembles the files. Each ko/<field>.ts holds the keys of the matching en/<field>.ts in the same order. The EN files generate / progress / script are intentionally empty, so they have no Korean counterpart.
    • It covers all 2,496 English UI entries. Two more keys are used in source through context.t() but have no EN entry yet (切换 WebCodecs…, 素材「{name}」已存在。…). Their Korean entries sit in exportPanel.ts / media.ts.
    • ko/templates-data.ts covers all 304 data display names: the 24 Chinese-key names for self-made templates (en/templates-data) and the 280 English-key names for built-in templates, sounds and music (zh/templates|sounds|music).
  • Translation approach: English was the source of truth and the Chinese original was a cross-reference. Every entry was reviewed in a second pass. The same Chinese key can appear in several places (as a menu title and as a sentence fragment), so each key has one Korean string that fits all of its uses.
  • Fallback: ko UI copy falls back to English, then to the Chinese key (uiFallback: EN). Data names fall back to EN_DATA, the same wiring as it. A string added to EN before Korean catches up shows in English, not Chinese.
  • Server-side copy:
    • localized() in server/ui-locale.ts accepts an optional ko variant and falls back to English. No server message has a ko variant yet, so they all show in English for Korean users, the same as Italian today.
    • The phone upload page (server/mobile-upload-service.ts) gets a full Korean copy, and ?locale=ko is accepted.
  • Transcription language selectors already list Korean (韩语(ko)), so settingsMediaProviders.ts is unchanged.

Out of scope

  • Template propSchema field labels are English in the original source for every locale, so they stay as they are.
  • Font names are proper names and are not translated.
  • Hard-coded English fallbacks in src/agent/toolFailure.ts / serverRunToolEnvironment.ts (handled for zh/ru only) show English for ko, the same as it.

Verification

New executable check:

  • src/i18n/dict/ko/coverage.verify.ts, wired into npm run verify:i18n. It asserts that every EN key has a non-empty Korean entry, that every Korean entry has the same {placeholder} set as its EN entry (or as the Chinese key when EN has none), and that every data name in EN_DATA + ZH_DATA has a Korean display name.

Extended checks:

  • src/i18n/locale.verify.ts: switching to ko persists cc.locale=ko and sets <html lang="ko">.
  • src/i18n/dictRegistry.verify.ts: ko reads KO, translates both Chinese-key and English-key data names, and is wired to EN / EN_DATA as fallbacks.
  • src/agent/systemPromptOrder.verify.ts: the ko response-language prompt names Korean.
  • server/mobile-upload-service.verify.ts: a ko session serves <html lang="ko"> with Korean copy.
  • server/plugins/mobile-upload.verify.ts: ?locale=ko reaches createSession('ko').

Commands:

  • npm run lint: passes (exit 0; warnings only, all pre-existing)
  • npm test: passes, 197/197 segments (631 registered verify files, including pretest verify:i18n and posttest)
  • npm run build: tsc -b and vite build pass, and so do the other prebuild steps (sync-shader-sources --check, sync:mediapipe, verify:server-tool-catalog). On the macOS machine used here, prebuild's sync:whisper-cli stops before compiling because cmake is not installed (cmake is required to build whisper.cpp). That step is environment-dependent and does not touch this change; CI runs the full npm run build.
  • Korean is emitted as its own lazy chunk (ko-*.js, ~202 kB / 72 kB gzip), so it does not grow the entry chunk.

scripts/verify-gate-coverage.verify.mjs exempts src/i18n/dict/ko/settings.ts (531 lines) from the 500-line source limit, the same as en/settings.ts. It mirrors en/settings.ts key for key and holds only dictionary data.

Screenshots

Web mode with localStorage['cc.locale'] = 'ko'.

Home (project list)

Home (project list)

Editor (example project)

Editor (example project)

Top bar language button (한)

Top bar language button (`한`)

Settings

Settings

Export dialog

Export dialog

Captions panel

Captions panel

🤖 Generated with Claude Code

Add Korean as a UI locale alongside zh/en/it/ru. The dictionary mirrors
dict/en's per-domain split and covers every English entry plus all
template, sound and music data names. Untranslated keys fall back to
English (then Chinese), matching Italian.

- locale: ko type, system-language detection, <html lang>, agent
  response language, top bar label 한
- dictRegistry: lazy ko chunk with EN/EN_DATA fallbacks
- server: ui-locale accepts ko (English fallback); the phone upload
  page gets Korean copy
- verify: ko/coverage.verify.ts (EN key coverage, placeholder parity,
  data names) in verify:i18n; ko cases in locale, dictRegistry,
  systemPromptOrder and mobile-upload verifies

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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