Skip to content

Commit 2068e03

Browse files
feat(i18n): serve labels by i18n.sourceLocale as the authored language (#34025)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9S57hqQnFxsopofbjbzbR6p)_ Fixes #33634 Clause-②: yes Metadata-protocol: semantic Skills-docs: follow-up #34053 ## 维护者速读 - 改了什么:运行时现在读取 `i18n.sourceLocale`,把它当作元数据内联标签的原文语言;i18n 服务契约新增可选的 `getSourceLocale` / `setSourceLocale`。 - 为什么改:英文写元数据、默认给用户中文的应用,没配 `fallbackLocale` 时,英文请求拿到的是中文标签;工具已把 `en` 报成 100% 覆盖,运行时却不这么服务。 - 风险与回滚:只影响声明了 `sourceLocale` 的应用;没声明的应用答案逐字不变(每个入口都有对照测试)。回滚即 revert 本 PR。 - 先看:`packages/spec/src/contracts/i18n-service.ts`(新契约方法的语义)、`packages/rest/src/meta-item-read-gate.ts`(元数据读取的取值顺序)、`packages/runtime/src/app-plugin.ts`(声明如何注入服务)。 - 两分钟验证:`pnpm --filter @objectstack/rest exec vitest run src/meta-i18n-declared-fallback-chain.test.ts`,预期 25 个测试全绿,其中 §6 六个是本卡的钉子。 - 需要你做的:无,席位落地。 ## What changes An app authored in English that defaults its users to `zh-CN` (`defaultLocale: 'zh-CN'`, `sourceLocale: 'en'`, no `fallbackLocale`, a `zh-CN` pack) used to serve an `en` request the Chinese row: every caller that builds the label resolver's options passed `getDefaultLocale()` as `ResolveOptions.defaultLocale` (the authored language), so `en` was not "the authored one" and walked the fallback chain (`zh-CN`, the boot paths' collapse) ahead of the inline text. Route A of the census report (issuecomment 6894743586), chosen by the seat: - **Contract** (`packages/spec/src/contracts/i18n-service.ts`): optional `getSourceLocale(): string | undefined` and `setSourceLocale(locale): void`. Same stance as the fallback pair: implementing one does not oblige the other (per-value); the getter answers only what was declared and never derives `defaultLocale` — that collapse is the caller's. The `getDefaultLocale` jsdoc no longer claims it is always the authored language. - **Producers**: `AppPlugin.loadTranslations` threads `i18n.sourceLocale` beside `setDefaultLocale` / `setFallbackLocale`, guarded on "declared something" (a sibling app on the same kernel keeps its value). `FileI18nAdapter` and the kernel's in-memory fallback implement both halves. Measured: `os serve` and plugin-dev construct `I18nServicePlugin` with `defaultLocale` / `fallbackLocale` only, and `AppPlugin` then calls the setters on the adapter it built, so neither boot path needed a new option (`serve.ts`, `dev-i18n.ts` untouched). - **The five option builders**, each now `getSourceLocale()` (non-empty) else `getDefaultLocale()` as `ResolveOptions.defaultLocale`, fallback chain untouched: rest `metaTranslateOptions` (also behind `RestServer.translateOptionsFor`, `form-routes.ts` and the runtime dispatcher's list translation), objectql `formula-option-labels.ts`, plugin-email `option-label-table.ts`, service-analytics `translateSelectOptions`, service-storage `record-file-access.ts` `labelsIn`. The census re-run on `895783a1` (every non-test `fallbackChain` / `getDefaultLocale` reader under `packages/`) found no sixth builder; the only other `fallbackChain` site is `ui/packages/i18n/src/utils/spec-formatters.ts`, a client formatter fed from its own config, not from `II18nService` (noted below). - **Users'-default readers unchanged**: service-messaging recipient locale and notification text, runtime `domains/i18n.ts`, discovery, AppPlugin seed locale, `extractLocale` (a header-less request still falls to `defaultLocale`), plugin-auth (not touched). - **Prose made false, corrected in the same PR**: `TranslationConfigSchema.sourceLocale` jsdoc and `.describe` ("Not yet read by the serving layer"), `ResolveOptions.defaultLocale` jsdoc and the resolver header, the `RestServer.translateOptionsFor` docblock, the regenerated `content/docs/references/system/translation.mdx`, and three hand-written doc pages that described the old rule or told authors to add `fallbackLocale: 'en'` as a workaround. Shared read helper: inline (five 3-line copies); no new `@objectstack/spec/system` export. ## Tests Each builder has a pin with `defaultLocale: 'zh-CN'`, `sourceLocale: 'en'`, no `fallbackLocale` (collapsed to `zh-CN`): an `en` request answers the inline English label, a `zh-CN` request the `zh-CN` row, and a CONTROL with no `sourceLocale` keeps today's answer (`zh-CN` row for `en`). - rest `meta-i18n-declared-fallback-chain.test.ts` §6: single read, list read, header-less request (falls to `zh-CN`), a third locale (`ja-JP` walks the chain to `zh-CN`), controls with the accessor absent and answering `undefined`. - objectql `engine-formula-option-label.test.ts`, plugin-email `template-option-labels.integration.test.ts` (booted kernel), service-analytics `picklist-dimension-label-i18n.test.ts` (both strategies), service-storage `record-file-access.integration.test.ts` (the upload-link page, English and Chinese). - Producers: `fallbacks.test.ts` (memory provider), `file-i18n-adapter.test.ts`, `app-plugin.test.ts` (threads, does not call when undeclared, skips a provider without the setter), spec `i18n-service.test.ts`. - Forced test edits: none. Two harness widenings to reach the pins: the rest file's `protocol()` / `makeRest()` take an optional document map, and the plugin-email `AppFixture` takes accessor overrides; every existing case runs with the defaults it had. <details><summary>Readings (local, shared container; packages built at the head the suites ran on)</summary> - Full suites, the nine consumer packages (downstream direction: the packages that read the widened contract), one locked run: spec 842 files / 26958 tests, core 147 / 3404, objectql 596 / 13174, service-i18n 4 / 73, plugin-email 53 / 1020, service-analytics 215 / 5220 (335 skipped), service-storage 86 / 1652 (1 skipped), rest 412 / 8448 (332 skipped), runtime 605 / 10961 (19 skipped): all passed. Typecheck green in all nine (runtime's test layer after building `driver-turso`, a devDependency outside the first build closure). - Ablation, one per changed builder plus the producer (`scripts/ablation-replace.mjs`, mutation proven on disk, file restored to its HEAD blob each time): rest source read removed → 2 of 25 red (§6 single and list read); objectql → 1 of 9 red; plugin-email → 1 of 4 red; service-analytics → 2 of 30 red (one per strategy); service-storage → 1 of 90 red; `AppPlugin` `setSourceLocale` call removed → 1 of 39 red. Each test file imports the source under test, so no rebuild was needed for the legs. - `pnpm --filter @objectstack/spec check:generated`: one stale artifact (`content/docs/references/system/translation.mdx`), regenerated; `api-surface` unchanged (an optional interface member). </details> ## Acceptance notes - `ui/packages/i18n/src/utils/spec-formatters.ts` builds a `fallbackChain` from its own client config, not from `II18nService`; it is outside this route (the Console's own locale config). Not filed. - A regional request in the source language (`en-US` against `sourceLocale: 'en'`) is not recognised as the authored one: `isDefaultLocale` compares tags exactly (case-insensitive), the same as it always did for `defaultLocale`. Unchanged by this PR; noted, not filed. ## Verification Verification head: `b63efd08`, a merge-only commit of `origin/main` (`e71ecc1b`, 15 commits past the previous merge) made under the seat's K ≥ 15 landing rule; CI on this head is the landing verdict. No file this PR changes moved on main's side. The local readings below were taken at `5156e558` (suites, ablations, derived gates, HTTP door) and `74a2954d` (the first merge of `main`: full rebuild, `check:generated` green with nothing to regenerate). <details><summary>HTTP door, booted</summary> The todo example in a side worktree at this head, set to `defaultLocale: 'zh-CN'`, `sourceLocale: 'en'`, no `fallbackLocale`, and its `en` bundle dropped (so English can only come from the inline labels); `pnpm dev --fresh`, signed in as the dev admin, `GET /api/v1/meta/object/todo_task`: - `Accept-Language: en` → `Task` / `Tasks` / field `Subject` (inline English) - `Accept-Language: zh-CN` → `任务` / `任务` / `主题` - `Accept-Language: ja-JP` → `タスク` / `タスク` / `件名` - no header → `任务` (the users' default) - CONTROL, same stack without `sourceLocale`: `en` → `任务` / `任务` / `主题` (the card's defect, unchanged for a stack that declares nothing). The example edits lived only in that throwaway worktree; it was removed after both servers were stopped. </details> <details><summary>Derived gates (head 5156e55)</summary> `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` on head `5156e558`: 130 commands, all run, all exit 0; `--ran` reconciliation: 130 derived, 130 run, 0 NOT-MEASURED, 0 UNRUN. The first round (head `75656a8b`) found one real red, `check:test-source-alias` on the edited rest test (the routes reach `@objectstack/objectql` through a dynamic import inside a case's clock); fixed in `5156e558` with a module-top `import '@objectstack/objectql'`, the shape the package's other door tests use. Its other two non-zero exits were environment: `check-plugin-teardown-shape --self-test` exit 3 until its pinned commit was fetched into the shallow clone, and `check:generated`'s embedded `check:test-typecheck` tsc run failing without diagnostics at the default heap (green at the CI heap, 4096 MB). </details> <!-- signed: domain:spec#2 · os-steve · session_01ADHkmRFB7DnbZ57susY8Uv --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent fa1fb6f commit 2068e03

28 files changed

Lines changed: 562 additions & 70 deletions
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
'@objectstack/spec': minor
3+
'@objectstack/core': minor
4+
'@objectstack/runtime': minor
5+
'@objectstack/service-i18n': minor
6+
'@objectstack/rest': minor
7+
'@objectstack/objectql': minor
8+
'@objectstack/plugin-email': minor
9+
'@objectstack/service-analytics': minor
10+
'@objectstack/service-storage': minor
11+
---
12+
13+
feat(i18n): the serving layer reads `i18n.sourceLocale` as the authored label's language
14+
15+
Clause-②: yes
16+
Metadata-protocol: semantic
17+
18+
`II18nService` (`@objectstack/spec/contracts`) gains an optional `getSourceLocale()` / `setSourceLocale(locale)` pair, shaped like the fallback pair; `FileI18nAdapter` and the kernel's in-memory fallback implement both.
19+
20+
An app authored in one language that defaults its users to another now serves its inline labels to a request in the authored language. Take `defaultLocale: 'zh-CN'`, `sourceLocale: 'en'`, English inline labels, a `zh-CN` bundle and no `fallbackLocale`:
21+
22+
- Before: an `en` request was not treated as the authored language, walked the fallback chain (`zh-CN`) ahead of the inline text and was served the Chinese bundle row, unless the stack also declared `fallbackLocale: 'en'`.
23+
- Now: an `en` request answers the English inline label; a `zh-CN` request answers the `zh-CN` row; any other locale walks the declared fallback chain exactly as before.
24+
25+
`AppPlugin` threads the declared `i18n.sourceLocale` into the i18n service, and every metadata-document translation (the REST metadata reads, a formula's `label()`, an email template's `option` hole, analytics select-option labels and the upload-link page) passes `getSourceLocale()`, else `getDefaultLocale()`, as `ResolveOptions.defaultLocale`. A stack that declares no `sourceLocale` is served exactly as before. A `fallbackLocale: 'en'` added only to work around this can stay; it is no longer needed for the `en` request.
26+
27+
Writing your own i18n provider: implement `setSourceLocale` to receive the declaration and `getSourceLocale` to report it, answering `undefined` when nothing was declared — never `defaultLocale`; the serving layer does that collapse itself.

‎content/docs/kernel/services-checklist.mdx‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -485,15 +485,18 @@ AppPlugin will, in this order:
485485
1. Set the default locale via `i18nService.setDefaultLocale()`
486486
2. Set the declared `i18n.fallbackLocale` — the locale `t()` consults after the requested
487487
one — via `i18nService.setFallbackLocale()` (#15694)
488-
3. Narrow what `getLocales()` REPORTS to the app's declared `supportedLocales`, via
488+
3. Set the declared `i18n.sourceLocale` — the language the inline labels are written in —
489+
via `i18nService.setSourceLocale()` (#33634); the serving layer reads it back through
490+
`getSourceLocale()`, else `getDefaultLocale()`, as the authored label's language
491+
4. Narrow what `getLocales()` REPORTS to the app's declared `supportedLocales`, via
489492
`i18nService.setSupportedLocales()` (#7679)
490-
4. Call `i18nService.loadTranslations(locale, data)` for each locale in every bundle
491-
5. Skip gracefully if no i18n service is registered (no errors, just a debug log)
493+
5. Call `i18nService.loadTranslations(locale, data)` for each locale in every bundle
494+
6. Skip gracefully if no i18n service is registered (no errors, just a debug log)
492495

493-
Each of the three setters is optional on `II18nService` and applied through the same
496+
Each of the four setters is optional on `II18nService` and applied through the same
494497
`typeof ... === 'function'` capability probe, so a provider that has not implemented one
495498
keeps its own behaviour rather than breaking. `FileI18nAdapter` implements
496-
`setDefaultLocale` and `setSupportedLocales` but **not** `setFallbackLocale`: both boot
499+
`setDefaultLocale`, `setSourceLocale` and `setSupportedLocales` but **not** `setFallbackLocale`: both boot
497500
paths (`os serve` and `DevPlugin`'s auto-wiring) construct it with
498501
`fallbackLocale || defaultLocale || 'en'` already collapsed from the stack config, so the
499502
probe skips step 2 and it keeps the value it was built with — omitting a setter is

‎content/docs/protocol/kernel/i18n-standard.mdx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,10 @@ Fallback to: en (system default) ✓
234234

235235
The "system default" step is the stack's **declared** fallback
236236
(`i18n.fallbackLocale`, else `defaultLocale`), never a literal `en`. For
237-
metadata labels one more rule applies (#15711): the inline `label:` authored
238-
on the metadata **is** the default locale's text, so a request for
239-
`defaultLocale` stops at the authored label without consulting any other
240-
locale's bundle — a `zh-CN` workspace with a courtesy `en` bundle serves
237+
metadata labels one more rule applies (#15711, #33634): the inline `label:`
238+
authored on the metadata **is** the source locale's text (`sourceLocale`, else
239+
`defaultLocale`), so a request for that locale stops at the authored label
240+
without consulting any other locale's bundle — a `zh-CN` workspace with a courtesy `en` bundle serves
241241
Chinese to `zh-CN` and English to `en`. See
242242
[Translations](/docs/ui/translations#how-a-locale-is-chosen).
243243

‎content/docs/references/system/translation.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ Internationalization configuration
539539
| **defaultLocale** | `string` | ✅ | Default locale (e.g., "en") |
540540
| **supportedLocales** | `string[]` | ✅ | Supported BCP-47 locale codes |
541541
| **fallbackLocale** | `string` | optional | Fallback locale code |
542-
| **sourceLocale** | `string` | optional | Language the inline metadata text (a plain-string label) is written in, when it differs from defaultLocale (e.g. "en" for an English-authored app whose users default to "zh-CN"). Absent, it is defaultLocale. Read by os lint, os i18n check and os i18n extract as the source language; their --default-locale flag overrides it. Not yet read by the serving layer: the runtime label resolvers still treat defaultLocale as the authored label's language. |
542+
| **sourceLocale** | `string` | optional | Language the inline metadata text (a plain-string label) is written in, when it differs from defaultLocale (e.g. "en" for an English-authored app whose users default to "zh-CN"). Absent, it is defaultLocale. Read by os lint, os i18n check and os i18n extract as the source language; their --default-locale flag overrides it. The serving layer reads it as the authored label's language too: a request in this locale is answered from the inline text. |
543543

544544

545545
---

‎content/docs/ui/translations.mdx‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,10 @@ the next best text.
188188

189189
Two rules keep the declaration honest (#14882, #15711):
190190

191-
- **The authored label is the default locale's text.** A request for
192-
`defaultLocale` consults that locale's own bundle and then answers with the
193-
inline `label:` — it never walks the fallback chain. A stack declaring
191+
- **The authored label is the source locale's text.** A request for the
192+
language the inline labels are written in — `sourceLocale` when declared,
193+
else `defaultLocale` (#33634) — consults that locale's own bundle and then
194+
answers with the inline `label:`; it never walks the fallback chain. A stack declaring
194195
`defaultLocale: 'zh-CN'` with `fallbackLocale: 'en'` and only an `en` bundle
195196
serves its authored Chinese to a `zh-CN` request, and its `en` bundle to
196197
everyone else. Shipping a `zh-CN` bundle (`os i18n extract --locales=zh-CN`)
@@ -372,9 +373,9 @@ default one, and your inline `label:` is already that locale's text — so there
372373
is no gap to report and no need to reach for `--skip-i18n`. The same holds if
373374
your source language isn't English: declare `defaultLocale: 'zh-CN'` and the
374375
tooling stops asking for English you never promised. The runtime reads the
375-
declaration the same way (#15711): a request for the default locale answers
376-
with the authored label, so what the gate counts as covered is what gets
377-
served.
376+
declaration the same way (#15711, #33634): a request for the source locale
377+
answers with the authored label, so what the gate counts as covered is what
378+
gets served.
378379

379380
#### When users default to a language you did not author in
380381

@@ -400,12 +401,12 @@ language every user without a preference is served. Declare `defaultLocale: 'zh-
400401
reads your English labels as Chinese: it reports every key missing in `en` and
401402
never reports a `zh-CN` gap.
402403

403-
`sourceLocale` is read by the authoring tools only. The runtime's
404-
authored-label rule above still keys on `defaultLocale`, so in this setup it is
405-
the `zh-CN` request that skips the fallback chain, and an `en` request walks
406-
the declared fallback (`fallbackLocale`, else `defaultLocale`) before it
407-
reaches the English inline label. Declare `fallbackLocale: 'en'` to keep an
408-
`en` request on the authored text.
404+
The runtime reads `sourceLocale` too (#33634): its authored-label rule above
405+
keys on it, so in this setup an `en` request answers the English inline label
406+
without walking the fallback chain, a `zh-CN` request is served the `zh-CN`
407+
rows, and any other locale walks the declared fallback (`fallbackLocale`, else
408+
`defaultLocale`) before it reaches the inline text. No `fallbackLocale: 'en'`
409+
is needed to keep an `en` request on the authored text.
409410

410411
Translating is therefore opt-in, but once you opt in it covers the **whole**
411412
declared surface — every row of the table above, including action labels

‎packages/core/src/fallbacks/fallbacks.test.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,28 @@ describe('createMemoryI18n declared fallbackLocale (#15694)', () => {
660660
expect(typeof i18n.setFallbackLocale).toBe('function');
661661
expect(i18n.getFallbackLocale).toBeUndefined();
662662
});
663+
664+
// #33634 — the source-locale pair: unlike the fallback pair, both halves
665+
// exist, because the accessor answers only what it was told.
666+
it('getSourceLocale answers undefined until setSourceLocale is called, then exactly what it was told', () => {
667+
const i18n = createMemoryI18n();
668+
i18n.setDefaultLocale('zh-CN');
669+
// Never derived from `defaultLocale`: that collapse is the caller's.
670+
expect(i18n.getSourceLocale()).toBeUndefined();
671+
i18n.setSourceLocale('en');
672+
expect(i18n.getSourceLocale()).toBe('en');
673+
expect(i18n.getDefaultLocale()).toBe('zh-CN');
674+
});
675+
676+
it('setSourceLocale changes no t() lookup', () => {
677+
const i18n = createMemoryI18n();
678+
i18n.setDefaultLocale('zh-CN');
679+
i18n.loadTranslations('en', { greeting: 'Hello' });
680+
i18n.loadTranslations('zh-CN', { other: '其他' });
681+
const before = [i18n.t('greeting', 'zh-CN'), i18n.t('greeting', 'en'), i18n.t('other', 'en')];
682+
i18n.setSourceLocale('en');
683+
expect([i18n.t('greeting', 'zh-CN'), i18n.t('greeting', 'en'), i18n.t('other', 'en')]).toEqual(before);
684+
});
663685
});
664686

665687
// #30456: the one matcher for "is this locale offered here, and as which code",

‎packages/core/src/fallbacks/memory-i18n.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ export function createMemoryI18n() {
106106
// must leave `t()` answering exactly as it did before this existed — an app
107107
// that never wrote a `fallbackLocale` is not opting into a longer chain.
108108
let fallbackLocale: string | undefined;
109+
// [#33634] The app's DECLARED `i18n.sourceLocale` — the language its inline
110+
// labels are written in — injected by `AppPlugin.loadTranslations` beside
111+
// the other three. `undefined` means the app declared nothing, and the
112+
// serving layer then reads `defaultLocale` as the authored language, as it
113+
// always has. It changes no `t()` lookup.
114+
let sourceLocale: string | undefined;
109115

110116
/**
111117
* Resolve a dot-notation key from a nested object.
@@ -257,5 +263,22 @@ export function createMemoryI18n() {
257263
setFallbackLocale(locale: string): void {
258264
fallbackLocale = locale;
259265
},
266+
267+
/**
268+
* @see II18nService.getSourceLocale — [#33634]
269+
*
270+
* Unlike the fallback pair, the accessor IS implemented here: it answers
271+
* only what {@link setSourceLocale} was told, `undefined` otherwise, so it
272+
* never has to derive a value — the collapse to `defaultLocale` is the
273+
* serving layer's, not this provider's.
274+
*/
275+
getSourceLocale(): string | undefined {
276+
return sourceLocale;
277+
},
278+
279+
/** @see II18nService.setSourceLocale — [#33634] */
280+
setSourceLocale(locale: string): void {
281+
sourceLocale = locale;
282+
},
260283
};
261284
}

‎packages/objectql/src/engine-formula-option-label.test.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,30 @@ describe('#26608 — label() reads the option label in the reader\'s locale', ()
188188
expect(b.display_name).toBe('v2 · Clean');
189189
});
190190
});
191+
192+
describe('#33634 — the declared sourceLocale, not defaultLocale, is the authored option label\'s language', () => {
193+
// An app authored in English that defaults its users to zh-CN: `defaultLocale:
194+
// 'zh-CN'`, `sourceLocale: 'en'`, no `fallbackLocale` (collapsed to zh-CN by
195+
// both boot paths), English inline option labels, a zh-CN pack.
196+
const enSource = (overrides: Record<string, unknown> = {}) => makeI18n({
197+
getDefaultLocale: () => 'zh-CN',
198+
getFallbackLocale: () => 'zh-CN',
199+
getSourceLocale: () => 'en',
200+
...overrides,
201+
});
202+
const en = { locale: 'en' } as never;
203+
204+
it('an en reader gets the inline English label; a zh-CN reader gets the pack', async () => {
205+
const { engine } = await makeEngine(enSource());
206+
const a = await engine.insert('ol_version', { version_no: 2, kind: 'clean' }, { context: en }) as Rec;
207+
expect(a.display_name).toBe('v2 · Clean');
208+
const b = await engine.insert('ol_version', { version_no: 3, kind: 'redline' }, { context: zhCN }) as Rec;
209+
expect(b.display_name).toBe('v3 · 修订稿');
210+
});
211+
212+
it('CONTROL — no sourceLocale declared: an en reader walks the chain to zh-CN, as before', async () => {
213+
const { engine } = await makeEngine(enSource({ getSourceLocale: () => undefined }));
214+
const a = await engine.insert('ol_version', { version_no: 2, kind: 'clean' }, { context: en }) as Rec;
215+
expect(a.display_name).toBe('v2 · 清稿');
216+
});
217+
});

‎packages/objectql/src/engine-references-and-master-detail.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export class ReferencesAndMasterDetailFacet {
101101
getTranslations?: (locale: string) => Record<string, unknown>;
102102
getFallbackLocale?: () => string | undefined;
103103
getDefaultLocale?: () => string | undefined;
104+
getSourceLocale?: () => string | undefined;
104105
}): void {
105106
this.i18nService = service;
106107
this.logger.info('I18nService configured for validation messages');

‎packages/objectql/src/engine.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ export class ObjectQL implements IObjectQLEngine {
621621
getTranslations?: (locale: string) => Record<string, unknown>;
622622
getFallbackLocale?: () => string | undefined;
623623
getDefaultLocale?: () => string | undefined;
624+
getSourceLocale?: () => string | undefined;
624625
};
625626

626627
// Crypto provider backing `secret`-typed fields. Optional: when absent,
@@ -2544,6 +2545,7 @@ export class ObjectQL implements IObjectQLEngine {
25442545
getTranslations?: (locale: string) => Record<string, unknown>;
25452546
getFallbackLocale?: () => string | undefined;
25462547
getDefaultLocale?: () => string | undefined;
2548+
getSourceLocale?: () => string | undefined;
25472549
}): void {
25482550
// [#29986 codemod] The body moved to `engine-references-and-master-detail.ts` (see `ReferencesAndMasterDetailHost`).
25492551
return ReferencesAndMasterDetailFacet.setI18nService.call(referencesAndMasterDetailHost.of(this), service);

0 commit comments

Comments
 (0)