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
14 changes: 14 additions & 0 deletions .changeset/34962-i18n-skill-texts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
'@objectstack/skills': patch
---

docs(skills): the i18n and ui skills teach the `mappings` translation group, an action's `texts` and where hook and action texts sit in a bundle; the stale label-serving caveat is gone

Clause-②: no
Metadata-protocol: none

- `objectstack-i18n`: the top-level group list names `mappings` (`mappings.{mapping}.label`, an import mapping's label by its `name`). The paragraph on keys picked in the organization's language now covers the sentences a hook or a `script` action declares in `texts` and writes through `ctx.text`: `hooks.{hook}.texts.{key}.message` and `_actions.{action_name}.texts.{key}.message`, also under `globalActions`.
- `objectstack-i18n`: the caveat that label serving reads inline text as `defaultLocale` text is removed, because serving honours `i18n.sourceLocale`. What is still true stays: validation and refusal messages read labels through `t()`, which falls back to `fallbackLocale`, else `defaultLocale`, so an English-source app with a zh-CN default still declares `fallbackLocale: 'en'`.
- `objectstack-ui` `rules/actions.md`: a `script` action declares a sentence it writes into a record under `texts` and asks for it with `ctx.text`. The rule covers the organization's language, the `texts.<key>.message` key beside the refusals key, a missing translation, an unreadable Localization setting and an undeclared key. Two sentences that restated the example below them are shorter.
- `objectstack-i18n` pays for its new text in the same file. It drops a sentence that restated the option-key paragraph, two flags from the `extract --help` list that are taught in place, two partial copies of the group list, and the empty "Translate" step.
- Evals: the i18n set gains a `mappings` case and a hook-texts bundle-key case, and case 11 states the remaining `t()` reason for `fallbackLocale: 'en'`. The ui set gains an action `texts` case.
17 changes: 16 additions & 1 deletion scripts/check-skills-token-ratchet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,22 @@ export const CEILINGS = new Map([
// in the text that row moved in). Same ruling as the lines above (2026-10-27, tap A):
// 「A:先削重复,余额按实测提高」 (ruling record 6513306068).
// ceil($(wc -c < skills/objectstack-ui/rules/actions.md) / 4) == ceil(12720 / 4)
['skills/objectstack-ui/rules/actions.md', 3180],
// 3180 -> 3333 (#35097): a script action writes a sentence in the organization's language.
// One H3 after the refusals paragraph: declare it under `texts`, ask for it with `ctx.text`, the
// missing-translation and unreadable-setting answers, when an undeclared key is refused, and the
// `texts.<key>.message` key beside the refusals key the paragraph above spells (that key stays:
// the bundle's evals grade `_actions` and the with-skill arm reads this bundle only). PAID DOWN
// FIRST by 53 bytes of restatement in this file, each of an example right below its sentence:
// " as `${result.output.NAME}`" in the `onSuccess` sentence (27; the Convert Lead block's
// `${result.output.opportunity_id}` shows the spelling) and "`{recordId}` placeholder; " in the
// `newTabUrl` sentence (26; the Open PDF block's `newTabUrl: '/api/v1/invoice/{recordId}/pdf'`
// shows it). Nothing else in the file restates another passage (see the 2777 -> 2808 note
// above), so the same ruling's second half carries the rest. Arithmetic: the text adds 663
// bytes, the cuts remove 53, so the file is 12720 -> 13330 bytes -> 3333 tokens, zero headroom
// before, ceiling +153, the measured remainder only, pinned AT the measurement. Same ruling
// (2026-10-27, tap A): 「A:先削重复,余额按实测提高」 (ruling record 6513306068, letter B).
// ceil($(wc -c < skills/objectstack-ui/rules/actions.md) / 4) == ceil(13330 / 4)
['skills/objectstack-ui/rules/actions.md', 3333],
// 6090 -> 6252 (#19715, card item 4): a 5-line table of contents at the top,
// anchors to the file's existing headings, nothing else changed. +162 tokens,
// zero headroom to absorb any of it, ceiling +162. Maintainer ruling
Expand Down
42 changes: 19 additions & 23 deletions skills/objectstack-i18n/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ export default defineStack({
| Property | Type | Required / Default | Description |
|:---------|:-----|:-------------------|:------------|
| `defaultLocale` | `string` | **required** | The locale a user who has not chosen one gets |
| `sourceLocale` | `string` | optional, defaults to `defaultLocale` | The language inline `label:` text is written in; read by `os lint`, `os i18n check`, `os i18n extract` |
| `sourceLocale` | `string` | optional, defaults to `defaultLocale` | The language inline `label:` text is written in: a request in it is served that text; read by `os lint`, `os i18n check`, `os i18n extract` |
| `supportedLocales` | `string[]` | **required** | All supported locales |
| `fallbackLocale` | `string` | optional | Fallback when translation missing |

An app authored in English for Chinese users declares `defaultLocale: 'zh-CN', sourceLocale: 'en'`,
not an English `defaultLocale`. ⚠️ Label serving still reads inline text as `defaultLocale` text: with no
`fallbackLocale: 'en'`, an `en` request reaches the zh-CN bundle before the English inline label.
not an English `defaultLocale`. ⚠️ Validation and refusal messages still read labels through `t()`, which
falls back to `fallbackLocale`, else `defaultLocale`: without `fallbackLocale: 'en'` an `en` refusal names
a field by its zh-CN row.
`sourceLanguage`, `authoringLocale` and `authoringLanguage` are refused, each naming `sourceLocale`.

---
Expand Down Expand Up @@ -179,7 +180,8 @@ picklist inherits them), `dashboards`, `datasets`, `reports`, `pages`, `flows`,
spine, by `Book.name`: `books.{book}.label` / `.description`, and `groups.{group_key}.label` by
each group's stable `key`, never its position — `books.crm_manual.groups.getting_started.label`;
the pages themselves localize through `doc.translations`, and the inline `translations` map a
book once carried stays retired), `metadataForms`, `settingsCommon`; `reports`, `positions` and
book once carried stays retired), `mappings` (an import mapping's `label` by its `name`:
`mappings.{mapping}.label`), `metadataForms`, `settingsCommon`; `reports`, `positions` and
`permissions` hold `label` + `description` by name, so do `datasets` and each dataset member at
`datasets.{dataset}.{dimensions,measures}.{member}` (a member's `synonyms` have no key: one
authored list carries every language), and a joined report's block headings sit at
Expand All @@ -188,17 +190,20 @@ Three keys sit deeper than their group's `label`: a `page:tabs` item at
`pages.{page}.components.{tabs_id}.items.{value}.label` (by the item's `value`; an item without
one has no key), an approval step at `flows.{flow}.approvals.{node_id}.label`, and the text a
`create_record` / `update_record` writes into a field marked `{ dialect: 'template', source }` at
`flows.{flow}.records.{node_id}.fields.{field}`, picked in the organization's language (the
Localization setting if set, else `i18n.defaultLocale`; never the run starter's).
`flows.{flow}.records.{node_id}.fields.{field}`. That text, and each sentence a hook or a `script`
action declares in `texts` and writes through `ctx.text` — `hooks.{hook}.texts.{key}.message`,
`_actions.{action_name}.texts.{key}.message` (also under `globalActions`) — is picked in the
organization's language (the Localization setting if set, else `i18n.defaultLocale`; never the caller's).
`os i18n extract --no-objects-only` scaffolds every group above but `messages` and
`settingsCommon`, all three keys included. The `inlineTitle`, report-block and table-column
keys, as the shipped `app-crm`, `app-showcase` and platform bundles spell them for `zh-CN`
`settingsCommon`, all three keys included. The `inlineTitle`, report-block, table-column and
mapping keys, as the shipped `app-crm`, `app-showcase` and platform bundles spell them for `zh-CN`
(`rows` is the table field's `path`, `error.message` one column's):

```typescript
objects: { crm_opportunity_line_item: { fields: { opportunity: { inlineTitle: '产品明细' } } } },
reports: { showcase_task_overview: { blocks: { open_block: { label: '未完成任务' } } } },
objects: { sys_user: { _actions: { import_sso_users: { resultDialog: { columns: { rows: { email: '邮箱', 'error.message': '未添加的原因' } } } } } } },
mappings: { showcase_inquiry_feed: { label: '询盘导入(营销 CSV)' } },
```

`settings` is **platform-only** — it is keyed by a settings manifest's namespace and only
Expand Down Expand Up @@ -234,9 +239,7 @@ whose column path that field's `columns[]` does not list;
under an action that declares neither `confirmText` nor a non-empty `params` — a bundle
translates a dialog the action declares and cannot add one. A
param's inline option keys share the option warning with a field's `options`; a param that
references a `field` and declares no inline `options` is not judged. A bundle keyed to
something since renamed still parses — the label just renders silently in its source locale
while every neighbouring one resolves.
references a `field` and declares no inline `options` is not judged.

---

Expand Down Expand Up @@ -305,8 +308,7 @@ os i18n check --strict --threshold=95 # CI gate: locale parity + minimum covera
```

It compares registered bundles against source metadata and reports missing keys
per locale for every surface the extractor walks — objects and their sub-keys,
global actions, apps, dashboards, pages, flow screens. The platform's metadata
per locale for every surface the extractor walks. The platform's metadata
forms count only for a stack that ships their translations (`--include-platform`
audits them anyway). Gaps in the source locale are errors, `--strict` promotes
the rest, `--show-keys` lists them all; `os lint --i18n-strict` folds it in.
Expand Down Expand Up @@ -426,19 +428,13 @@ This writes `<locale>.objects.generated.ts` TypeScript modules (not JSON), plus
the source locale is filled from schema labels, other locales follow `--fill`
(`empty | default | todo`). `--default-locale` overrides the source locale for one run
(`i18n.sourceLocale`, else `i18n.defaultLocale`, else `en`). `os i18n extract --help` lists
the rest: `--filter`, `--no-merge`, `--objects-only`, `--source-hashes`, `--dry-run`, `--json`, …
the rest: `--filter`, `--no-merge`, `--dry-run`, `--json`, …

⚠️ **`--objects-only` is on by DEFAULT**, so extract writes only the `objects` /
`globalActions` subtree — while `os i18n check` also demands `app`, `navigation`,
`dashboard`, `widget`, `dataset`, `report`, `picklist`, `page`, `flow`, `position` and
`permission` keys. Pass `--no-objects-only` to include those
groups, or author them by hand.
`globalActions` subtree while `os i18n check` still asks for the other groups: pass
`--no-objects-only`, or author them by hand.

### 2. Translate

Fill in the values manually.

### 3. Register
### 2. Register

A stack registers its bundles with `defineStack({ translations: [...] })`. A **package or
plugin shipping its own generated bundle** — the most common shape in this repo — has one
Expand Down
22 changes: 21 additions & 1 deletion skills/objectstack-i18n/evals/bundles-locales-coverage.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
{
"id": 11,
"prompt": "Our app's metadata is authored in English — every inline `label:` is English — but it is sold to Chinese users, who should get Chinese without choosing a language. How do we declare the stack's `i18n` config?",
"expected_output": "Declare `sourceLocale: 'en'` beside `defaultLocale: 'zh-CN'` in the stack's `i18n` block, with `zh-CN` in `supportedLocales`: `defaultLocale` is the locale a user who has not chosen one gets, `sourceLocale` the language the inline labels are written in. `os lint`, `os i18n check` and `os i18n extract` then treat `en` as the source — extract fills the `en` bundle from the inline text, and the rows the tooling asks for are the zh-CN ones. Also declare `fallbackLocale: 'en'`: label serving still reads inline text as `defaultLocale` text, so without it an `en` request reaches the zh-CN bundle before the English inline label.",
"expected_output": "Declare `sourceLocale: 'en'` beside `defaultLocale: 'zh-CN'` in the stack's `i18n` block, with `zh-CN` in `supportedLocales`: `defaultLocale` is the locale a user who has not chosen one gets, `sourceLocale` the language the inline labels are written in. `os lint`, `os i18n check` and `os i18n extract` then treat `en` as the source — extract fills the `en` bundle from the inline text, and the rows the tooling asks for are the zh-CN ones. Label serving then answers an `en` request from the English inline label. Also declare `fallbackLocale: 'en'`: validation and refusal messages still read labels through `t()`, which falls back to `fallbackLocale`, else `defaultLocale`, so without it an `en` refusal names a field by its zh-CN row.",
"files": [],
"assertions": {
"must_contain": ["sourceLocale", "defaultLocale: 'zh-CN'", "fallbackLocale: 'en'", "supportedLocales"],
Expand All @@ -130,6 +130,26 @@
"must_contain": ["_actions", "import_leads", "resultDialog.columns.rows", "error.message"],
"must_not_contain": ["error: {"]
}
},
{
"id": 14,
"prompt": "Our package ships a named import mapping `lead_csv` with `label: 'Lead CSV (standard)'`. zh-CN users still see that English label in the import wizard's saved-mapping picker. Where does the translation go?",
"expected_output": "`mappings.lead_csv.label` in the zh-CN `TranslationData`: `mappings` is a top-level group beside `objects`, keyed by the mapping's `name` — `mappings: { lead_csv: { label: '线索 CSV(标准)' } }`. `label` is the only key (a mapping declares no description). The mapped fields' own labels stay under `objects.<object>.fields.<field>.label`. Not an `objects` entry and not a `messages` key.",
"files": [],
"assertions": {
"must_contain": ["mappings", "lead_csv", "label"],
"must_not_contain": ["objects: { lead_csv", "messages: {"]
}
},
{
"id": 15,
"prompt": "The `lead_follow_up` hook declares `texts: { follow_up_subject: { message: 'Follow up with qualified lead: {{ lead }}', params: ['lead'] } }` and writes a task subject with `ctx.text('follow_up_subject', { lead: ctx.input.name })`. Our organization works in zh-CN, but the tasks still read English. Which bundle key translates it, and whose language is picked?",
"expected_output": "`hooks.lead_follow_up.texts.follow_up_subject.message` in the zh-CN bundle, keyed by the hook's `name` (not under `objects` or `messages`), the translation keeping its `{{ lead }}` hole, which the runtime fills after picking it: `'跟进已确认的线索:{{ lead }}'`. It is picked in the organization's language — the Localization setting if somebody set it, else `i18n.defaultLocale` — never the language of the person whose save fired the hook.",
"files": [],
"assertions": {
"must_contain": ["hooks", "lead_follow_up", "texts", "follow_up_subject", "defaultLocale"],
"must_not_contain": ["messages: {", "_hooks"]
}
}
]
}
10 changes: 10 additions & 0 deletions skills/objectstack-ui/evals/views-apps-actions-pages.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,16 @@
"must_contain": ["refusals", "NOT_DRAFT", "409", "_actions"],
"must_not_contain": ["hooks.submit_signoff"]
}
},
{
"id": 21,
"prompt": "The `send_email` script action on `crm_contact` logs a `crm_activity` whose subject its `js` body builds as `'Email: ' + input.subject`. Our organization works in zh-CN, but every logged subject reads English. Make the subject follow the organization's language.",
"expected_output": "The action declares `texts: { email_subject: { message: 'Email: {{ subject }}', params: ['subject'] } }` and the body writes `const subject = await ctx.text('email_subject', { subject: input.subject });` instead of concatenating. The sentence is answered in the organization's language (the Localization setting if somebody set it, else `i18n.defaultLocale`), never the language of the person who pressed the button, and translated at `objects.crm_contact._actions.send_email.texts.email_subject.message`, the translation keeping its `{{ subject }}` hole. With no translation the declared sentence is written. A key `texts` does not declare is refused. Not a locale branch in the body, and not a `messages` lookup.",
"files": [],
"assertions": {
"must_contain": ["texts", "email_subject", "ctx.text", "_actions"],
"must_not_contain": ["hooks.send_email"]
}
}
]
}
14 changes: 12 additions & 2 deletions skills/objectstack-ui/rules/actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const ReassignLeadAction = defineAction({

## Examples

`onSuccess` hops once the flow run completes, not when it pauses at a screen; its URL template reads an `isOutput` variable as `${result.output.NAME}`:
`onSuccess` hops once the flow run completes, not when it pauses at a screen; its URL template reads an `isOutput` variable:

<!-- os:check -->
```typescript
Expand Down Expand Up @@ -141,6 +141,16 @@ sentence is answered as `userMessage`, translated at
`objects.<object>._actions.<action>.refusals.<CODE>.message` (objectstack-i18n); the console's
failure toast shows it unless the action authors `errorMessage`.

### Writing in the organization's language (`texts`)

A sentence the body writes into a record (an activity's subject) is read organization-wide:
the same actions declare it under `texts` and ask for it by key —
`texts: { email_subject: { message: 'Email: {{ subject }}', params: ['subject'] } }`, then
`await ctx.text('email_subject', { subject: input.subject })`. It answers in the organization's
language, never the caller's, translated at the same node's `texts.<key>.message`; with no
translation the declared sentence is written, filled; an unreadable Localization setting
rejects. An undeclared key is refused at save when named literally, else at run.

## Opening in a New Tab

### `openIn: 'new-tab'`
Expand Down Expand Up @@ -168,7 +178,7 @@ export const PrintA3Action = defineAction({
A redirect URL **computed after a fetch**: `opensInNewTab:
true` pre-opens the tab synchronously on click (no popup blocker), then navigates
it to the handler's `redirectUrl`. `newTabUrl` skips the round-trip — a backend
path starting with `/` (`{recordId}` placeholder; an external URL is refused, use
path starting with `/` (an external URL is refused, use
`openIn`), valid only with `opensInNewTab: true`; the endpoint enforces its own
auth (the tab carries no in-app session).

Expand Down
Loading