From a359107dd45cdb81463f11db53acd09ae5cb94a0 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 19:54:04 +0000 Subject: [PATCH] docs(skills,spec): name the dispatcher as the owner of the i18n routes Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01L6bhgUpnvPnJ1hR74pUrVj --- .changeset/37625-i18n-routes-owner.md | 11 +++++++++++ packages/spec/src/api/protocol.zod.ts | 7 ++++--- packages/spec/src/system/i18n-resolver.ts | 5 +++-- skills/objectstack-i18n/SKILL.md | 15 ++++++++------- 4 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 .changeset/37625-i18n-routes-owner.md diff --git a/.changeset/37625-i18n-routes-owner.md b/.changeset/37625-i18n-routes-owner.md new file mode 100644 index 00000000000..09fc6d54065 --- /dev/null +++ b/.changeset/37625-i18n-routes-owner.md @@ -0,0 +1,11 @@ +--- +'@objectstack/skills': patch +'@objectstack/spec': patch +--- + +docs(skills,spec): the i18n skill and two spec comments name the dispatcher as the owner of the `/api/v1/i18n/*` routes + +Clause-②: no (published prose and comments only; no behaviour changes) +Metadata-protocol: none + +`skills/objectstack-i18n/SKILL.md` (Registration) said the i18n service "self-registers" `GET /api/v1/i18n/locales`, `/translations/:locale` and `/labels/:object/:locale`. On `main` `I18nServicePlugin` mounts no HTTP route (retired by #23347); the runtime's HTTP dispatcher, which `os serve` composes, mounts the three paths and serves them from the i18n service. The sentence now says so, and the methods list gains `getSourceLocale()` / `setSourceLocale()`, which both shipped implementations provide (`getFallbackLocale()` is left out: the in-memory fallback deliberately has none). The words are paid for by tightening four phrasings in the same file; no fact is removed. The `GetLocalesResponseSchema` docblock (`packages/spec/src/api/protocol.zod.ts`) and the `toLocaleDescriptors` comment (`packages/spec/src/system/i18n-resolver.ts`) make the same correction. diff --git a/packages/spec/src/api/protocol.zod.ts b/packages/spec/src/api/protocol.zod.ts index 31d618ee9e3..96dcce363e4 100644 --- a/packages/spec/src/api/protocol.zod.ts +++ b/packages/spec/src/api/protocol.zod.ts @@ -4872,9 +4872,10 @@ export const GetLocalesRequestSchema = lazySchema(() => z.object({})); * * `label` is the locale CODE, echoed back. Every descriptor on every serving * surface comes from one helper — `toLocaleDescriptors` - * (`system/i18n-resolver.ts`), shared by the runtime dispatcher's `/i18n` - * domain and `service-i18n`'s autonomous route — and it sets `label` to the - * code, because nothing in the tree carries a locale name to set it from. + * (`system/i18n-resolver.ts`), called by the runtime dispatcher's `/i18n` + * domain, the one owner of the route (`service-i18n` mounts none since + * #23347) — and it sets `label` to the code, because nothing in the tree + * carries a locale name to set it from. * * This describe used to read "Display name of the locale" while no producer * ever wrote one: the declared-not-enforced shape ADR-0049 is about, one field diff --git a/packages/spec/src/system/i18n-resolver.ts b/packages/spec/src/system/i18n-resolver.ts index fd7fc702d2c..9a71fe3273f 100644 --- a/packages/spec/src/system/i18n-resolver.ts +++ b/packages/spec/src/system/i18n-resolver.ts @@ -4401,8 +4401,9 @@ export interface LocaleDescriptor { * Turn `II18nService.getLocales()` — a bare `string[]` — into the descriptor * list `GetLocalesResponseSchema` declares for `GET /i18n/locales`. * - * Shared for the same reason `resolveObjectFieldLabels` is: both the - * dispatcher domain and service-i18n serve this route, and when each kept its + * Shared for the same reason `resolveObjectFieldLabels` is: the dispatcher + * domain and service-i18n both once served this route (service-i18n's mount + * was retired by #23347; the dispatcher owns it), and when each kept its * own copy they diverged. service-i18n mapped to descriptors; the dispatcher * passed the raw `string[]` straight through, so the SAME endpoint returned * `['en','zh-CN']` or `[{code,label,isDefault}]` depending on which provider diff --git a/skills/objectstack-i18n/SKILL.md b/skills/objectstack-i18n/SKILL.md index f85fc499101..89ade39e39a 100644 --- a/skills/objectstack-i18n/SKILL.md +++ b/skills/objectstack-i18n/SKILL.md @@ -354,17 +354,17 @@ resolves keys with fallback: import type { II18nService } from '@objectstack/spec/contracts'; ``` -(Only `src/**/*.zod.ts` ships, so the contract's `.ts` source is not in `node_modules` to read.) +(Only `src/**/*.zod.ts` ships, so the contract's `.ts` source is not in `node_modules`.) -Methods implemented by both shipped adapters (`FileI18nAdapter` from +Methods both shipped adapters implement (`FileI18nAdapter` from `@objectstack/service-i18n`, and the in-memory fallback `@objectstack/core` registers when no i18n plugin is present): - **`t(key, locale, params?)`** — dot-path resolution (e.g. `objects.account.label`) with `{{param}}` interpolation and fallback-locale lookup -- **`getTranslations(locale)`** — full snapshot for a locale +- **`getTranslations(locale)`** — a locale's full snapshot - **`loadTranslations(locale, data)`** — programmatic load (deep-merge) -- **`getLocales()`** / **`setSupportedLocales()`** / **`getDefaultLocale()`** / **`setDefaultLocale()`** +- **`getLocales()`** / **`setSupportedLocales()`** / **`getDefaultLocale()`** / **`setDefaultLocale()`** / **`getSourceLocale()`** / **`setSourceLocale()`** The in-memory fallback additionally resolves locale codes through `resolveLocaleAmong` (`@objectstack/spec/system`), the one ladder `resolveBundleLocale` also runs: exact → @@ -378,10 +378,11 @@ points for a custom workbench or TMS adapter. (`getAppBundle` / ### Registration -You do not wire this plugin: `os serve` registers `I18nServicePlugin` itself whenever the +Don't wire this plugin: `os serve` registers `I18nServicePlugin` itself whenever the stack config carries `translations` or `i18n` (kernel bootstrap is -**objectstack-platform → Runtime Boot Sequence**). It self-registers -`GET /api/v1/i18n/locales`, `/translations/:locale` and `/labels/:object/:locale`; the locales +**objectstack-platform → Runtime Boot Sequence**). The runtime's HTTP dispatcher, +which `os serve` composes, mounts `GET /api/v1/i18n/locales`, `/translations/:locale` and +`/labels/:object/:locale`, served from the i18n service; the locales answer marks the default locale (`isDefault`) and names `sourceLocale` (the declared one, else the default). ---