Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/37625-i18n-routes-owner.md
Original file line number Diff line number Diff line change
@@ -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.
7 changes: 4 additions & 3 deletions packages/spec/src/api/protocol.zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions packages/spec/src/system/i18n-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 8 additions & 7 deletions skills/objectstack-i18n/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 →
Expand All @@ -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).

---
Expand Down
Loading