diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 104cec73e..12837ea4f 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -1,20 +1,50 @@ # Contributors -Thank you to everyone who contributes code, fixes, tests, translations, documentation, and feedback to DeepTutor. Git history preserves original authors and coauthors; the [GitHub contributors page](https://github.com/HKUDS/DeepTutor/graphs/contributors) also records contributions to the default branch. +Thank you to everyone who contributes code, fixes, tests, translations, documentation, and feedback to DeepTutor. The repository history preserves individual commit authors and coauthors; the [GitHub contributors page](https://github.com/HKUDS/DeepTutor/graphs/contributors) also records contributions to the default branch. ## Contributions integrated into dev after v1.7.0 -This list acknowledges contributions on the development branch before the next release reaches the default branch. It supplements the project's existing contributor history. +These contributors are acknowledged explicitly on the development branch so their contributions are visible before the next release reaches the default branch. This list supplements the project’s existing contributor history. + +### Newly acknowledged contributors - [@0x-IHRR](https://github.com/0x-IHRR) — [#2128](https://github.com/HKUDS/DeepTutor/pull/2128). -- [@amartinawi](https://github.com/amartinawi) — [#2169](https://github.com/HKUDS/DeepTutor/pull/2169). +- [@1akashkalita](https://github.com/1akashkalita) — [#2142](https://github.com/HKUDS/DeepTutor/pull/2142). +- [@alphaliujin](https://github.com/alphaliujin) — [#2161](https://github.com/HKUDS/DeepTutor/pull/2161). +- [@amartinawi](https://github.com/amartinawi) — [#2169](https://github.com/HKUDS/DeepTutor/pull/2169), [#2190](https://github.com/HKUDS/DeepTutor/pull/2190), [#2191](https://github.com/HKUDS/DeepTutor/pull/2191), [#2192](https://github.com/HKUDS/DeepTutor/pull/2192), [#2193](https://github.com/HKUDS/DeepTutor/pull/2193), [#2194](https://github.com/HKUDS/DeepTutor/pull/2194). +- [@Antonio-Faure](https://github.com/Antonio-Faure) — [#2203](https://github.com/HKUDS/DeepTutor/pull/2203), [#2204](https://github.com/HKUDS/DeepTutor/pull/2204), [#2206](https://github.com/HKUDS/DeepTutor/pull/2206), [#2216](https://github.com/HKUDS/DeepTutor/pull/2216). +- [@bcfernando](https://github.com/bcfernando) — [#2202](https://github.com/HKUDS/DeepTutor/pull/2202). - [@bercedev](https://github.com/bercedev) — [#2167](https://github.com/HKUDS/DeepTutor/pull/2167). +- [@czcjsxmhqydncgg1](https://github.com/czcjsxmhqydncgg1) — [#2159](https://github.com/HKUDS/DeepTutor/pull/2159). +- [@d41sys](https://github.com/d41sys) — [#2174](https://github.com/HKUDS/DeepTutor/pull/2174). - [@Eapp1e](https://github.com/Eapp1e) — [#2197](https://github.com/HKUDS/DeepTutor/pull/2197), [#2215](https://github.com/HKUDS/DeepTutor/pull/2215). +- [@erhanurgun](https://github.com/erhanurgun) — [#2135](https://github.com/HKUDS/DeepTutor/pull/2135). +- [@fanjiahe](https://github.com/fanjiahe) — [#2208](https://github.com/HKUDS/DeepTutor/pull/2208). - [@Frank-zhu2000](https://github.com/Frank-zhu2000) — [#2127](https://github.com/HKUDS/DeepTutor/pull/2127). +- [@harshdazz](https://github.com/harshdazz) — [#2187](https://github.com/HKUDS/DeepTutor/pull/2187). +- [@HenryZhu123](https://github.com/HenryZhu123) — [#2163](https://github.com/HKUDS/DeepTutor/pull/2163). +- [@hongthana](https://github.com/hongthana) — [#2162](https://github.com/HKUDS/DeepTutor/pull/2162), [#2176](https://github.com/HKUDS/DeepTutor/pull/2176), [#2180](https://github.com/HKUDS/DeepTutor/pull/2180). - [@hydraxman](https://github.com/hydraxman) — [#2131](https://github.com/HKUDS/DeepTutor/pull/2131). -- [@kevin9327](https://github.com/kevin9327) — [#2225](https://github.com/HKUDS/DeepTutor/pull/2225). -- [@KKandLL-Forever](https://github.com/KKandLL-Forever) — [#2149](https://github.com/HKUDS/DeepTutor/pull/2149). -- [@Rimcat-JA](https://github.com/Rimcat-JA) — [#2232](https://github.com/HKUDS/DeepTutor/pull/2232). -- [@rudycelekli](https://github.com/rudycelekli) — [#2198](https://github.com/HKUDS/DeepTutor/pull/2198), [#2199](https://github.com/HKUDS/DeepTutor/pull/2199), [#2200](https://github.com/HKUDS/DeepTutor/pull/2200), [#2226](https://github.com/HKUDS/DeepTutor/pull/2226), [#2227](https://github.com/HKUDS/DeepTutor/pull/2227), [#2228](https://github.com/HKUDS/DeepTutor/pull/2228), [#2233](https://github.com/HKUDS/DeepTutor/pull/2233), [#2234](https://github.com/HKUDS/DeepTutor/pull/2234), [#2235](https://github.com/HKUDS/DeepTutor/pull/2235), [#2236](https://github.com/HKUDS/DeepTutor/pull/2236), [#2237](https://github.com/HKUDS/DeepTutor/pull/2237), [#2238](https://github.com/HKUDS/DeepTutor/pull/2238), [#2239](https://github.com/HKUDS/DeepTutor/pull/2239), [#2240](https://github.com/HKUDS/DeepTutor/pull/2240). +- [@iriseye395](https://github.com/iriseye395) — [#2146](https://github.com/HKUDS/DeepTutor/pull/2146). +- [@jayhemnani9910](https://github.com/jayhemnani9910) — [#2157](https://github.com/HKUDS/DeepTutor/pull/2157), [#2158](https://github.com/HKUDS/DeepTutor/pull/2158). +- [@juunghyun](https://github.com/juunghyun) — [#2178](https://github.com/HKUDS/DeepTutor/pull/2178), [#2185](https://github.com/HKUDS/DeepTutor/pull/2185). +- [@kevin9327](https://github.com/kevin9327) — [#2160](https://github.com/HKUDS/DeepTutor/pull/2160), [#2225](https://github.com/HKUDS/DeepTutor/pull/2225). +- [@knowhycodata](https://github.com/knowhycodata) — [#2156](https://github.com/HKUDS/DeepTutor/pull/2156). +- [@markjoin123](https://github.com/markjoin123) — [#2223](https://github.com/HKUDS/DeepTutor/pull/2223). +- [@maxsheng215-cyber](https://github.com/maxsheng215-cyber) — [#2170](https://github.com/HKUDS/DeepTutor/pull/2170). +- [@meconopscsh](https://github.com/meconopscsh) — [#2140](https://github.com/HKUDS/DeepTutor/pull/2140), [#2141](https://github.com/HKUDS/DeepTutor/pull/2141), [#2145](https://github.com/HKUDS/DeepTutor/pull/2145). +- [@mrhy7176](https://github.com/mrhy7176) — [#2138](https://github.com/HKUDS/DeepTutor/pull/2138). +- [@nandanadileep](https://github.com/nandanadileep) — [#2137](https://github.com/HKUDS/DeepTutor/pull/2137). +- [@Plastic-time](https://github.com/Plastic-time) — [#2218](https://github.com/HKUDS/DeepTutor/pull/2218). +- [@Rimcat-JA](https://github.com/Rimcat-JA) — [#2210](https://github.com/HKUDS/DeepTutor/pull/2210), [#2211](https://github.com/HKUDS/DeepTutor/pull/2211), [#2212](https://github.com/HKUDS/DeepTutor/pull/2212), [#2213](https://github.com/HKUDS/DeepTutor/pull/2213), [#2232](https://github.com/HKUDS/DeepTutor/pull/2232), [#2241](https://github.com/HKUDS/DeepTutor/pull/2241). - [@sriv144](https://github.com/sriv144) — [#2153](https://github.com/HKUDS/DeepTutor/pull/2153). -- [@x-labb](https://github.com/x-labb) — [#2219](https://github.com/HKUDS/DeepTutor/pull/2219). +- [@x-labb](https://github.com/x-labb) — [#2219](https://github.com/HKUDS/DeepTutor/pull/2219), [#2220](https://github.com/HKUDS/DeepTutor/pull/2220), [#2221](https://github.com/HKUDS/DeepTutor/pull/2221). +- [@ycccccc111](https://github.com/ycccccc111) — [#2182](https://github.com/HKUDS/DeepTutor/pull/2182). +- [@yuanyyt](https://github.com/yuanyyt) — [#2207](https://github.com/HKUDS/DeepTutor/pull/2207). +- [@yuleihaotong](https://github.com/yuleihaotong) — [#2179](https://github.com/HKUDS/DeepTutor/pull/2179). +- [@Zhi-Xiang-Guo](https://github.com/Zhi-Xiang-Guo) — [#2188](https://github.com/HKUDS/DeepTutor/pull/2188). + +### Returning contributors in this integration + +- [@KKandLL-Forever](https://github.com/KKandLL-Forever) — [#2149](https://github.com/HKUDS/DeepTutor/pull/2149). +- [@rudycelekli](https://github.com/rudycelekli) — [#2198](https://github.com/HKUDS/DeepTutor/pull/2198), [#2199](https://github.com/HKUDS/DeepTutor/pull/2199), [#2200](https://github.com/HKUDS/DeepTutor/pull/2200), [#2226](https://github.com/HKUDS/DeepTutor/pull/2226), [#2227](https://github.com/HKUDS/DeepTutor/pull/2227), [#2228](https://github.com/HKUDS/DeepTutor/pull/2228), [#2233](https://github.com/HKUDS/DeepTutor/pull/2233), [#2234](https://github.com/HKUDS/DeepTutor/pull/2234), [#2235](https://github.com/HKUDS/DeepTutor/pull/2235), [#2236](https://github.com/HKUDS/DeepTutor/pull/2236), [#2237](https://github.com/HKUDS/DeepTutor/pull/2237), [#2238](https://github.com/HKUDS/DeepTutor/pull/2238), [#2239](https://github.com/HKUDS/DeepTutor/pull/2239), [#2240](https://github.com/HKUDS/DeepTutor/pull/2240). diff --git a/docs-for-dev/I18N.md b/docs-for-dev/I18N.md new file mode 100644 index 000000000..983eda1e7 --- /dev/null +++ b/docs-for-dev/I18N.md @@ -0,0 +1,178 @@ +# Interface and reply languages + +DeepTutor has two language settings that are deliberately separate: + +- **Interface language** (`language`) selects the web UI locale: navigation, + settings, status text, deterministic backend copy and the CLI. +- **Model output language** (`response_language`) tells chat and the learning + capabilities which language to write reader-facing answers in. It supports + more languages than the interface. + +A language can be one, the other, or both. Adding a locale to the web picker +does not make the model answer in it, and adding a reply language does not +translate the UI. + +## Where the copy lives + +| Surface | Source | Fallback | +| --- | --- | --- | +| Web UI | `web/locales//app.json` (and `common.json` when present) | English, per missing key | +| Web language picker | `web/i18n/languages.ts` | — | +| Web date and time formatting | `web/lib/datetime.ts` | English (`en-US`) | +| Desktop shell | `apps/desktop/src/i18n.mjs` | English, per missing key | +| Reply-language picker | `web/features/settings/store/response-language-options.ts` (`RESPONSE_LANGUAGE_OPTIONS`) | — | +| Runtime normalizer | `deeptutor/services/settings/interface_settings.py` | English | +| Reply-language contract | `deeptutor/core/response_languages.py` | English | +| Prompt language directive | `deeptutor/services/prompt/language.py` | English | +| CLI banner and `deeptutor init` | `deeptutor/runtime/banner.py` | English | +| Backend API/MCP/sandbox messages | `deeptutor/services/i18n.py` | English | +| Book Overview page | `deeptutor/book/overview_copy.py` | English | +| Book Markdown export | `deeptutor/book/export.py` | English | +| Quiz judge | `deeptutor/api/routers/quiz_judge.py` | English | +| Partner "thinking…" notice | `deeptutor/services/partners/runtime.py` | English | + +Most web catalog keys are English copy; named keys such as `language.english` are also used. The runtime keeps +`keySeparator: false`, so natural-language keys such as `Generating...` are +looked up whole. A missing key falls back to English; a first-class locale is +expected to have **no missing keys**. + +`web/scripts/compact-locale-loader.cjs` removes entries whose key equals their +value at build time. Keep the authored JSON complete anyway: the Python locale +tests and the audit read the JSON files, not the compacted bundle. + +## Adding an interface language + +Use the existing French, German, Ukrainian and Polish locales as references. +A complete addition touches every row below; skipping one produces a language +that silently serves English on that surface. + +1. **Web locale registration** + - Add `{ code, labelKey }` to `APP_LANGUAGES` in `web/i18n/languages.ts`. + - Add the code to `normalizeLanguage()` so `fr-FR`, `fr_BE`, etc. resolve. + - Load the bundle in `ensureLanguage()` in `web/i18n/init.ts`. + - Add `language.` to every catalog. + - Register the appropriate regional locale in `getLocale()` in + `web/lib/datetime.ts`; test actual date and time formatting with an explicit + time zone so the test does not depend on the host's location. + +2. **Web catalog** + - Create `web/locales//app.json`. If the English tree ships a + `common.json` for the same namespace, mirror that file too. + - Cover every key in the English catalogs, and keep every `{{placeholder}}` + byte-identical, including repeated occurrences. + - Keep plural suffixes expected by i18next for that locale (`_one`, + `_other`, and `_many` where the language uses it). + - Do not translate product names, model ids, provider names, code + identifiers or literal placeholders such as `https://`. + - Do not reorder the existing English keys just to translate them; a focused + diff is easier to review. + +3. **Backend interface language** + - Add the code to `UiLanguage` and `_normalize_language()` in + `deeptutor/services/settings/interface_settings.py`. + - Add it to `_normalize_language()` in + `deeptutor/services/config/launch_settings.py` so CLI/startup language + overrides survive normalization. + - Add it to `_LANGUAGE_CHOICES` in + `deeptutor/services/config/settings_spec.py`. + +4. **Reply language, if the language is also offered for answers** + - Add it to `SUPPORTED_RESPONSE_LANGUAGES` in + `deeptutor/core/response_languages.py`. + - Add it to `ResponseLanguage` and `isResponseLanguage()` support in the shared + `web/i18n/languages.ts` / `web/context/app-shell-storage.ts` contract and to + `RESPONSE_LANGUAGE_OPTIONS` in + `web/features/settings/store/response-language-options.ts`. + - Add its label to `_LANGUAGE_LABELS` in + `deeptutor/services/prompt/language.py`. + - The shared partner reply-language picker reads `RESPONSE_LANGUAGE_OPTIONS`, + so no separate partner list is needed. + +5. **CLI and init wizard** + - Add the code to `_pick_language()` in `deeptutor/runtime/banner.py`. + - Add a `LABELS[code]` entry with exactly the same keys as `LABELS["en"]`. + +6. **Deterministic backend copy** + - Add `_MESSAGES[code]` and recognition in `_parse_language()` to + `deeptutor/services/i18n.py`. + - Add `_COPY[code]` to `deeptutor/book/overview_copy.py`. + - Add `_LABELS[code]` to `deeptutor/book/export.py`. + - Add a judge prompt to `_JUDGE_SYSTEM_PROMPTS` in + `deeptutor/api/routers/quiz_judge.py` if the judge should answer in that + language. + - Add a `_THINKING_NOTICES[code]` entry in + `deeptutor/services/partners/runtime.py` and preserve the language through + `PartnerRunner._language()`; otherwise the notice and turn context can + silently fall back to English. + - For explicit book-language requests, add the corresponding cues in + `deeptutor/book/language.py`. If the voice service offers the language, + register it in `deeptutor/services/voice/options.py` too. + +7. **Desktop shell** + - Add a complete dictionary and register it in `MESSAGES` in + `apps/desktop/src/i18n.mjs`. Preserve interpolation fields and intentional + line breaks, and verify language-region aliases through `resolveLanguage()`. + +8. **Generated contracts** + - When changing a schema or language union exposed by the API, run + `python scripts/export_frontend_contracts.py`, then + `npm --prefix web run contracts:generate` and commit the generated changes. + - After editing router source, run `python scripts/build_router_index.py`. + +9. **Tests** + - Add a locale test under `tests/i18n/` that checks catalog coverage, + placeholder parity, the language normalizer, the CLI banner, the backend + message table and any surface you touched. + - Run `npm run i18n:check` from `web/`; it checks English/Chinese parity and + audits used-key coverage. + - Keep locale-registry expectations and the synthetic locale fixtures in + `web/tests/i18n-audit.spec.ts` in sync; include each locale's plural forms. + - Run `npm run typecheck`, `npm run test:node`, `npm run lint`, and the + focused Vitest files. + - Run all Python locale tests, not only the new language's file: adding + English keys or language labels can break an existing locale's coverage. + A first-class locale must cover every English catalog key, not merely the + 65 % audit floor. Keep each locale's existing terminology consistent. + - Run the desktop shell language tests when adding shell copy. + +## Rules that keep languages from half-breaking + +- **No inline `{ en, zh }` maps and no `zh ? "..." : "..."` branches in + components.** Use `t()` with the English copy as the key so every locale can + translate it. Issue #2134 tracks the remaining instances. +- **Do not add a language to a picker before its catalog and backend seams + exist.** The picker will accept it and the app will quietly answer in English. +- **Keep interface and reply languages aligned when the product intent is the + same.** The settings page stores them separately; a user who picks French in + both places expects both to be French. +- **Partner reply language left empty means "Auto": follow the account's + `response_language`.** An explicit partner language wins. Use + `PartnerReplyLanguageSelect` rather than hand-writing the option list. +- **A missing translation is not an error at runtime**, but it is a regression + for a first-class locale. The fallback keeps the app usable; the tests keep + the gap visible. +- **Provider-returned error bodies are not translated.** They are shown as the + provider wrote them; map only DeepTutor-authored copy. + +## Verification + +From `web/`: + +```bash +npm run i18n:check +npm run typecheck +npx vitest run tests/partial-locale-fallback.spec.ts \ + tests/i18n-audit.spec.ts tests/provider-branding-locale.spec.tsx +npm run test:node +``` + +From the repository root: + +```bash +pytest -q tests/i18n tests/book/test_overview_copy.py +node --test apps/desktop/test/i18n.test.mjs +``` + +Add adjacent tests for any API, partner, book or judge surface you changed. +A locale PR should state which surfaces were checked and which were not; the +catalog test alone does not prove the CLI, book export or quiz judge. diff --git a/docs-for-dev/README.md b/docs-for-dev/README.md index f4cf4e875..93dcbd113 100644 --- a/docs-for-dev/README.md +++ b/docs-for-dev/README.md @@ -13,6 +13,7 @@ from the repository root unless a page says otherwise. | Install and configure the app | [Agent setup](AGENT_SETUP.md) → [Storage](DATA_STORAGE.md) | Dependencies, module readiness, actual model response, reachable app | | Fix an existing installation | [Setup troubleshooting](AGENT_SETUP.md#6-troubleshooting) → the relevant topic below | Original failing action works in the same instance and workspace | | Develop a change | [Development](DEVELOPMENT.md) → [Architecture](ARCHITECTURE.md) → [Testing](TESTING.md) | Focused regression and applicable project checks | +| Add or complete a UI language | [Languages](I18N.md) → [Testing](TESTING.md) | Catalog parity, typecheck, locale and surface tests | | Add a tool or capability | [Tool and capability contracts](TOOLS_AND_CAPABILITIES.md) → [Modules](MODULES.md) | Registration, availability, execution and terminal-result tests | | Build a third-party extension | [Plugins](PLUGINS.md) → [Runnable Learning Echo example](examples/learning_echo/README.md) | Wheel, manifest, approval, worker and frontend checks | | Investigate streaming or memory | [Events and progress](EVENTS_AND_PROGRESS.md) → [Runtime design](RUNTIME_DESIGN.md) | Persistence/replay and cancellation evidence | @@ -43,6 +44,8 @@ installation before deciding to reinstall it. model history and prompt-cache observability. - [Claude model synchronization](CLAUDE_MODEL_SYNC.md): SDK discovery, model catalogs and isolated provider sessions. +- [Languages](I18N.md): interface versus reply languages, catalog rules and + every seam a new locale must pass through. - [Remote Hermes backend](remote-hermes-backend.md): gateway protocol and Connected Agents integration.