You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c35fed1
Browse filesBrowse the repository at this point in the historyBrowse files
fix(service-datasource): serve the datasource driver form's labels and help in the requester's language (#30685)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DGazHPumEc1dceMjE3J1eEi)_Fixes#30563
Clause-②: no
Metadata-protocol: none
domain:server#1 card thread · session `session_016WV4czJVaL8SDBxjng4RLk`
· branch `claude/project-thread-b5t886` (the card thread's
platform-assigned branch, named in claim amendment 6670256081).
## 维护者速读
-
改了什么:新建数据源对话框里的驱动名称、驱动说明和每个连接字段的标题与说明(文件名、自动迁移表结构、主机、端口等),现在由服务端按请求语言返回;平台语言表上的
11 种语言全部齐全(简体、繁体、西、阿、法、葡(巴西)、俄、德、日、韩,英文为源文),英文界面不变。
- 为什么改:这些文字全部来自 `GET
/api/v1/datasources/drivers`,控制台自己没有对应的翻译键,所以中文界面里这一块一直是英文,和对话框其他中文文字混在一起。
- 风险与回滚:只改返回的文字,驱动
id、图标、字段类型、默认值和校验都不变;繁体读者(zh-TW、zh-HK)拿到繁体,不会落到简体;平台表之外的语言和产品名照旧返回英文。回滚即还原本
PR。
- 先看:`packages/services/service-datasource/src/driver-catalog.ts` 的
`driverCatalogLocaleOf` 与
`driverCatalogFor`;`src/driver-catalog-translations.ts`
的十种语言表;`src/admin-routes.ts` 里 drivers 路由那一行。
- 两分钟验证:`pnpm --filter @objectstack/service-datasource exec vitest run
src/__tests__/driver-catalog.test.ts
src/__tests__/admin-routes.test.ts`,预期 2 个文件 70 例全绿,其中 zh-CN
读到「文件名」,zh-TW 读到「檔案名稱」,fr-FR 读到 Nom de fichier,en-US 读到 Filename。
- 需要你做的:无,席位落地。
## What changes
- `GET /api/v1/datasources/drivers` reads the requester's language the
way the REST metadata door and the settings routes read it (the top
`Accept-Language` tag, else a string `?locale=`) and serves
`driverCatalogFor(locale)` instead of the fixed English
`DRIVER_CATALOG`. The console already sends its own language as
`Accept-Language` on every API call (`createAuthenticatedFetch` reads
the html `lang` attribute), so no `ui/` change is needed.
- `driverCatalogLocaleOf` (new, `driver-catalog.ts`) reads the requested
code through the platform locale table's own reader,
`platformLocaleTagOf` (`@objectstack/spec/system`), shortened one subtag
at a time (RFC 4647 lookup), the shape the storage connection test uses
(PR #30627). So `zh-TW`, `zh-HK`, `zh-MO` and `zh-Hant-TW` reach
`zh-Hant` and never the Simplified text; `zh`, `zh-CN`, `zh-SG` and
`zh-Hans-CN` reach `zh-Hans`; `pt` and `pt-PT` reach `pt-BR`; `fr-CA`
reaches `fr`. `driverCatalogFor` overlays that language's entry `label`
/ `description` and each top-level field's JSON-Schema `title` /
`description` on the English catalog. The spec's projected schema is
copied, never written.
- `driver-catalog-translations.ts` (new) holds the translations,
service-local beside the catalog's English curation, keyed by the
platform table's tags. Every non-English language on the table
(`zh-Hans`, `zh-Hant`, `es`, `ar`, `fr`, `pt-BR`, `ru`, `de`, `ja`,
`ko`) covers all five offered drivers (In-Memory, SQLite, PostgreSQL,
MySQL / MariaDB, MongoDB) and every field word the form draws. Each
language is written once as its distinct words and laid out per driver,
so a field the drivers share (host, port, password) reads one way.
Product names and technical terms (SQLite, URL, URI, SSL/TLS, `knex
searchPath`, `application_name`) are kept as they are.
- Fallback: no locale, `en`, a code the platform table does not name
(`it`, `nl-NL`), and the product-name labels are served the English
text, never a key. A translation only replaces a word the English form
shows; it never adds a title to a field that has none.
- Changeset: `@objectstack/service-datasource` patch.
## Tests
- `src/__tests__/driver-catalog.test.ts`, two new top-level describes.
`driverCatalogFor`: Simplified Chinese words for SQLite (`文件名`,
`自动迁移表结构`, the driver description) and the network drivers (`主机`, `端口`,
`密码`); a SQLite `filename` title of its own in each of the ten
languages, asserted against `PLATFORM_LOCALE_TAGS`; `zh-TW`, `zh-HK`,
`zh-MO`, `zh-Hant`, `zh-hant`, `zh-Hant-TW`, `zh-Hant-HK` reach
`zh-Hant` (`檔案名稱`) and `zh`, `zh-CN`, `zh-cn`, `zh-SG`, `zh-Hans`,
`zh-Hans-CN` reach `zh-Hans`; ten alias and regional codes (`ja-JP`,
`es-MX`, `pt-PT`, `fr-CA`, …) reach their table language; ids, icons,
field keys, types and defaults equal the English entry's in all eleven
languages; `undefined`, empty, `en`, `en-US`, `en-GB`, `it`, `nl-NL`,
`constructor`, `__proto__` return `DRIVER_CATALOG` itself; product-name
labels stay English; the spec projection and `DRIVER_CATALOG` still read
`Filename` after every language is served. `DRIVER_CATALOG_TRANSLATIONS
coverage` walks `PLATFORM_LOCALE_TAGS`, not the table's keys: the table
carries exactly the ten non-English languages; each names only drivers
and fields the catalog serves; each translates every driver description,
every non-product label and every field word the English form shows, so
a missing language or a field the spec adds goes red.
- `src/__tests__/admin-routes.test.ts`, one new case on the real
`HonoHttpServer`: `Accept-Language: zh-CN,zh;q=0.9,en;q=0.8` serves
`文件名`, `自动迁移表结构`, `主机`, `端口` and the zh MySQL description with the
English `SQLite` label; `?locale=zh-CN` with no header serves zh;
`zh-TW,zh;q=0.9` serves `檔案名稱` and `連接埠`; `fr-FR,fr;q=0.9` serves `Nom
de fichier`; `en-US` and `it-IT` serve `Filename` and `Host`.
## Acceptance notes
- **Languages.** All eleven languages on the platform locale table
(`PLATFORM_LOCALES`), English as the source, per the maintainer's
one-list ruling (no language tiers).
- **Out-of-scope finding (class a).** The dialog's own strings (the
console's `studio` namespace: the dialog title, Name, Display name,
Driver, Schema mode and its hints) exist in English and Chinese only
(`ui/packages/i18n/src/namespaces/studio/` holds `en.ts` and `zh.ts`),
so a console in any of the other nine languages now reads these driver
words in its own language inside an English dialog. Reach: the New
datasource dialog under Setup, console language set to any table
language other than en / zh-Hans; read from the tree, not measured live.
Not fixed here (`ui/**` is outside this card's surface). Dedupe words:
studio namespace locales, datasource dialog i18n, studio en zh only.
- **`?locale=` read.** The route now reads `?locale=` (string only, as
the settings routes and the metadata door do). It had no query read
before and declares no closed query set; converting this route to
`refuseUnknownQueryParams` is not done here.
- **Stale translations are not detected.** If the spec revises an
English field description, the zh-CN text stays as written; the coverage
test catches added and removed fields, not revised wording. Noted, not
filed.
- Nested schema words (the memory driver's persistence variants) are not
translated: the dialog draws only top-level properties.
- `DRIVER_CATALOG` keeps its value and stays the English catalog; the QA
checklist row that verifies the drivers body against it
(`docs/qa/platform-checklist/areas/integration-system.json`) still holds
for an English request.
## Verification
At head `2289fe00` (round 1 rework), after the
`@objectstack/service-datasource` dependency closure build.
<details><summary>Package suite and typecheck</summary>
- `pnpm --filter @objectstack/service-datasource test` (under
`os-verify-lock`): Test Files 72 passed (72), Tests 1239 passed (1239),
VERDICT command-exit 0.
- `pnpm --filter @objectstack/service-datasource typecheck`: VERDICT
command-exit 0 (`tsc --listFiles` includes both changed test files).
- `pnpm lint` (eslint . --no-inline-config): exit 0.
</details>
<details><summary>Ablations (scripts/ablation-replace.mjs, each restored
to blob == HEAD, git diff HEAD empty)</summary>
- Route ignores the requester (`driverCatalogFor(requestLocaleOf(req))`
to `driverCatalogFor(undefined)`): 1 failed / 69 passed, the route case.
- Title overlay deleted in `localizeField`: 4 failed / 66 passed
(Simplified words, every-language titles, Traditional codes, route
case).
- Schema written in place (`Object.assign(configSchema, …)` instead of a
copy): 3 failed / 67 passed (English fallback, spec projection
untouched, route case).
- Subtag shortening removed (only the whole code is looked up): 3 failed
/ 67 passed (Traditional codes via `zh-Hant-TW`, regional codes such as
`fr-CA` and `es-MX`, route case via `fr-FR`).
</details>
<details><summary>Derived gates (dispatch-gates --commands)</summary>
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`: 61 families derived at `2289fe00`; every
one exit 0 on the first pass (the round-0 prerequisites, the teardown
fixture commit and the whole-tree build, were still in place).
- `--ran` reconciliation: 61 derived, 61 run, 0 NOT-MEASURED, 0 UNRUN.
- `pnpm lint`: exit 0. `check-commit-card-trailers --range
origin/main..HEAD`: exit 0 (2 commits).
- Families CI runs beyond the derived set: read from this PR's
check-runs. The round-0 `TypeScript Type Check` red at `b475fae0` was
the aggregator over a lane cancelled by the push of `2289fe00` (run
42121322456: consumer gates `cancelled`, the other three lanes
`success`), not a type error.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_016WV4czJVaL8SDBxjng4RLk)_
<!-- signed: domain:server#1 · os-elon-musk ·
session_016WV4cytLmJxfAmgPVjUbbW -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(service-datasource): the datasource driver catalog serves its words in the requester's language, so the New datasource dialog reads in one language
6
+
7
+
Clause-②: no
8
+
Metadata-protocol: none
9
+
10
+
`GET /api/v1/datasources/drivers` now serves each driver's label and description, and each connection field's `title` and `description` (Filename, Auto-migrate schema, Host, Port, …), in the language the request names: the top `Accept-Language` tag, else `?locale=`. The code is read through the platform locale table (`platformLocaleTagOf`, shortened one subtag at a time), so `zh-TW` and `zh-HK` get Traditional Chinese, `zh`, `zh-CN` and `zh-SG` Simplified, `pt` Brazilian Portuguese and `fr-CA` French. Every language on the table is translated for every offered driver: Simplified and Traditional Chinese, Spanish, Arabic, French, Brazilian Portuguese, Russian, German, Japanese and Korean. English requests, codes the table does not name, and product names (SQLite, PostgreSQL, MySQL / MariaDB, MongoDB) are served the English text, never a key. `DRIVER_CATALOG` stays the English catalog, and the new `driverCatalogFor(locale)` in the package source builds the localized one; ids, icons, types and defaults are unchanged in every language.
0 commit comments