diff --git a/.changeset/37988-skills-i18n-packages-group.md b/.changeset/37988-skills-i18n-packages-group.md new file mode 100644 index 00000000000..a2fb859baeb --- /dev/null +++ b/.changeset/37988-skills-i18n-packages-group.md @@ -0,0 +1,14 @@ +--- +'@objectstack/skills': patch +--- + +docs(skills): `objectstack-i18n` teaches the bundle's `packages` group, and both related-list skills name the two ways a `.custom` arrangement's tab title is translated + +Clause-②: no +Metadata-protocol: none + +`skills/objectstack-i18n/SKILL.md`, the top-level group list: `packages` holds a package's display `name` / `description`, keyed by its `manifest.id` with the dotted id as one key (`packages: { 'com.acme.crm': { name: '客户关系' } }`). A locale with no row shows `manifest.name`, and `os lint` warns `i18n/missing-package` (`os i18n check` lists the same gap by key) until that package's own bundle carries the row. + +`skills/objectstack-i18n/SKILL.md`, the `_relatedLists.{list}` row, and `skills/objectstack-data/rules/relationships.md`, the `relatedLists` bullet: where the paired `.custom` arrangement leaves a list with no key, the remedy is to drop the key or re-state the entry, shown, with a `label`. The owner's own `label` keeps the owner's translation; a `label` of the arrangement's own is translated at the same `objects.{parent}._relatedLists.{list}.label` key in the `.custom` package's bundle, which `os i18n check` expects. + +Nothing an author can write changes. Neither file grows: `objectstack-i18n/SKILL.md` moves down to its measurement (6333 to 6315), the additions paid by replacing the translation-reference paragraph's list of action keys judged against a declaration, each already conditioned in the `_actions` row, with one sentence pointing at that row, and by dropping the code-comment tails that repeat the sentence introducing the first example; `rules/relationships.md` moves down too (4181 to 4179), paid by four restating phrases in the same file. diff --git a/content/docs/protocol/kernel/i18n-standard.mdx b/content/docs/protocol/kernel/i18n-standard.mdx index 6bc1adf2bd5..9a3494e5634 100644 --- a/content/docs/protocol/kernel/i18n-standard.mdx +++ b/content/docs/protocol/kernel/i18n-standard.mdx @@ -378,11 +378,23 @@ const zh: TranslationData = { apps: { crm: { label: '客户关系管理', navigation: { home: { label: '首页' } } } }, dashboards: { sales_overview: { label: '销售概览' } }, pages: { landing: { title: '欢迎' } }, + packages: { 'com.acme.crm': { name: '客户关系管理', description: '销售与客户管理' } }, // keyed by manifest.id globalActions: { export_csv: { label: '导出 CSV' } }, messages: { commonSave: '保存' }, }; ``` +`packages` is keyed by the package's `manifest.id`, and the dotted id is **one** +key: a client reads the row by direct property access, never as a dot path. A +key that is not a manifest id (a namespace like `crm`, a display name) is +refused at parse, as are `package` and the leaf spellings `label`, `title` and +`displayName`, each answered with the declared spelling. A row overlays the +manifest's own `name` / `description` where the console lists packages (Setup's +package list and Studio's package switcher); a package with no row for the +reader's locale shows its `manifest.name`, which stays the authored value on +every wire and in every editor. Each package ships the row for its own id in +the bundle it already carries. + **Key benefits:** - ✅ All translatable content for one object in one place - ✅ CLI can generate translation skeletons per object @@ -1221,6 +1233,14 @@ options: { 'Direct Mail': '直邮' } // ❌ keyed by the label — never resolv options: { 'direct-mail': '直邮' } // ❌ a variant spelling of the value ``` +`packages` keys are held to the manifest id grammar at parse and are not +resolved against the artifact's manifests here. Their coverage is a separate +report: `os i18n extract` scaffolds `packages.{id}.name` / `.description` for +the stack's manifest and every composed package. `os lint` reports a missing +one as the warning `i18n/missing-package`, and `os i18n check` lists the same +gap by its key; adding the row to that package's own bundle for the locale +clears both. + `messages`, `settingsCommon` and `metadataForms` are **not** checked: their keys are owned by application code, plugins, and the platform's own metadata-type registry rather than by this stack's metadata, so there is no set diff --git a/content/docs/ui/translations.mdx b/content/docs/ui/translations.mdx index 10b44b09de5..daf35a2e0d8 100644 --- a/content/docs/ui/translations.mdx +++ b/content/docs/ui/translations.mdx @@ -102,6 +102,7 @@ export default defineStack({ | Permission-set label / description | `permissions..label` / `description` — the group is spelled as the stack spells the collection (`permissions[]`), keyed by the set's `name` | | Doc book title, description and section titles | `books..label` / `description` / `groups..label` — keyed by the book's `name` and each group's `key`; overlaid on every served book and on the book tree, which is what the docs sidebar draws. A doc's own title and body localize through `doc.translations` instead | | Import mapping label | `mappings..label` — keyed by the mapping's `name`; overlaid on every served mapping, which is the list the import wizard offers by name. A mapping's `fieldMapping` holds column and field names, not copy: a target field's label is translated under `objects..fields..label` | +| Package name / description | `packages..name` / `description` — keyed by the package's `manifest.id` (reverse-domain, such as `com.acme.crm`; the dotted id is one key), never by its namespace or display name, which the parse refuses. Overlaid where the console lists packages: Setup's package list and Studio's package switcher, where a package that publishes an app is still named by the app's label. With no row for the reader's locale, a package shows its `manifest.name`. Each package ships the row for its own id in its own bundle | | Global actions, messages | `globalActions`, `messages` | | Settings UI shell copy (the source badge on a settings row) | `settingsCommon.sourceLabels.` — the per-namespace settings copy under `settings` is **platform-only**: an app bundle carrying it is refused by name, and the platform's own strings are translated in `@objectstack/service-settings`'s bundle | | A label written as an inline locale map (`label: { en: 'Members', 'zh-CN': '成员' }`) | Nowhere — it is written on the metadata and resolved at render time; see **Current boundaries** below | @@ -360,6 +361,19 @@ A missing string in the **default** locale is an error; missing strings in other locales are warnings until you set `--strict` / `--threshold`. The Todo example ships a completeness test alongside its bundles — worth copying. +A package's own display name is part of that report. `os i18n extract` scaffolds +`packages..name` / `.description` for the stack's manifest and +every composed package. `os lint` reports a missing one as the warning +`i18n/missing-package`, and `os i18n check` lists the same gap by its key +(`packages.com.acme.crm.name`). Clear it by adding the row to that package's +own bundle for the locale; the source locale needs one only when the displayed +name should differ from `manifest.name`: + +```typescript +// one locale of the package's own bundle (zh-CN) +packages: { 'com.acme.crm': { name: '客户关系管理', description: '销售与客户管理' } }, +``` + ### What counts as *your* coverage The Studio's own metadata forms (`metadataForms.*` — several hundred keys diff --git a/scripts/check-skills-token-ratchet.mjs b/scripts/check-skills-token-ratchet.mjs index b44ca19af85..f312124d40f 100644 --- a/scripts/check-skills-token-ratchet.mjs +++ b/scripts/check-skills-token-ratchet.mjs @@ -847,7 +847,19 @@ export const CEILINGS = new Map([ // the retired action location word `list_item` (-7 bytes); the row follows the measurement // down, 24384 bytes (24357 priced) -> 24377 (24350 priced) -> 6088 tokens. ['skills/objectstack-formula/SKILL.md', 6088], // -53 (was 6055), then -5 A2′ (was 6002), then +11 (was 5997), then +82 (was 6008), then -2 (was 6090) - ['skills/objectstack-i18n/SKILL.md', 6333], // -11 (was 6349), then -5 A2′ (was 6338) + // 6333 -> 6315: the top-level group list gains `packages` (`name` / `description` by + // `manifest.id`, the `os lint` warning `i18n/missing-package` and what clears it), and the + // `_relatedLists` row's remedy names both routes under a `.custom` arrangement (the owner's + // `label`, or the arrangement's own, read from the `.custom` package's bundle). Paid in full + // by deleting restatement in this file: the translation-reference paragraph's list of action + // keys judged against a declaration, each already conditioned in the `_actions` row (now one + // sentence pointing at that row, which gains "non-empty" on `submitText`), and the + // first example's three code-comment tails ("one TranslationData per locale", "assemble the + // locales into one bundle…", "…and register it on the stack"), which repeat the sentence + // introducing that example. No raise, no ruling spent: + // 25359 bytes (25332 priced) -> 25285 (25258 priced); the row follows the measurement down. + // ceil(($(wc -c < skills/objectstack-i18n/SKILL.md) - 27) / 4) == ceil(25258 / 4) + ['skills/objectstack-i18n/SKILL.md', 6315], // -11 (was 6349), then -5 A2′ (was 6338), then -18 (was 6333) // 12705 -> 12984 (2026-08-31 app-repo-principles raise, see the block above). // The largest of the five and the frame the other four are read under: what an // app IS (metadata under the platform's spec, authored from these skills, @@ -1381,7 +1393,15 @@ export const CEILINGS = new Map([ // 4201 -> 4181: the roll-up visibility paragraph no longer asks to remove Modify All before // masking a summary (19: it overrides no mask). 16801 -> 16723 bytes. // ceil($(wc -c < skills/objectstack-data/rules/relationships.md) / 4) == ceil(16723 / 4) - ['skills/objectstack-data/rules/relationships.md', 4181], // -2 to the measurement (was 4203) + // 4181 -> 4179: the `relatedLists` bullet's remedy under a `.custom` arrangement names the + // arrangement's own `label` beside the owner's (translated in the `.custom` package's + // bundle). Paid by deleting restatement in this file: "(cascade delete)" in the type table + // (the Delete Behaviors section states it), "to aggregate" after the roll-up intro, and the + // grid example's "(a field group names invoice_line, as above)", and "places the lines and" + // in the inline-entry example's comment (the prose above it says so). 16724 -> 16714 bytes; + // the row follows the measurement down. + // ceil($(wc -c < skills/objectstack-data/rules/relationships.md) / 4) == ceil(16714 / 4) + ['skills/objectstack-data/rules/relationships.md', 4179], // -2 to the measurement (was 4203), then -2 (was 4181) // NEW FILE (#14296 item 1 = A, condition (b)): the entry's Security & Access // Control block moved here whole. Pinned at its landed count — no headroom, // because a split that arrives with budget is a raise wearing a new path. diff --git a/skills/objectstack-data/rules/relationships.md b/skills/objectstack-data/rules/relationships.md index 3cfaff19487..95b8a47bdc2 100644 --- a/skills/objectstack-data/rules/relationships.md +++ b/skills/objectstack-data/rules/relationships.md @@ -11,7 +11,7 @@ | Type | Lifecycle | Required | Sharing | Roll-ups | Use Case | |:-----|:----------|:---------|:--------|:---------|:---------| | `lookup` | Independent | Optional by default | Independent | Via `summary` | "Related to" | -| `master_detail` | Coupled (cascade delete) | Forced only under `controlled_by_parent`, unless the optional master (below); else lint-warned | Inherits parent; read-on-master opt-ins (below) | Via `summary` | "Owned by" | +| `master_detail` | Coupled | Forced only under `controlled_by_parent`, unless the optional master (below); else lint-warned | Inherits parent; read-on-master opt-ins (below) | Via `summary` | "Owned by" | | `tree` | Self-reference | Optional — and so is `reference`, which when written must name this object itself; any other object is refused at parse, not lint-warned | N/A | Not available | Hierarchical | ## Patterns @@ -188,7 +188,7 @@ transaction. } ``` -`object` is the child object to aggregate, `field` its field (ignored for +`object` is the child object, `field` its field (ignored for `count`), `function` one of `count` / `sum` / `min` / `max` / `avg`. Optional: `filter` (below) and `relationshipField` (omitted: the child's `lookup` / `master_detail` referencing this parent). Refused at publish when omitted and the @@ -254,7 +254,7 @@ and parent + children save in **one atomic transaction**. A parent or child declaring `enable.apiMethods` must list `'bulk'`, or that save is refused `405 OBJECT_API_METHOD_NOT_ALLOWED`. ```typescript -// PARENT `invoice`: the group places the lines and holds no fields +// PARENT `invoice`: the group holds no fields fieldGroups: [{ key: 'lines', label: 'Line Items', relatedList: 'invoice_line' }], // CHILD `invoice_line`: its master_detail FK, declaring no `relatedList` @@ -289,7 +289,7 @@ editable fields, else `grid`. **Modeling a `'grid'` line item for the full editor:** ```typescript -// Parent (a field group names invoice_line, as above) +// Parent Invoice = { fields: { tax_rate: Field.number({ label: 'Tax Rate (%)' }), // → live Subtotal/Tax/Total stack @@ -360,7 +360,8 @@ audit_ref: { type: 'master_detail', reference: 'invoice', relatedList: false }, arrangement re-stating the entry with no `label`, or hiding it, leaves none (a bare child's name, labelled or not, covers each of its `child.field` lists too) and `os validate` refuses the key: drop it, or re-state the entry, shown, with the - owner's `label`. A child in the stack with no inbound FK + owner's `label`, or the arrangement's own, translated at that key in the `.custom` + package's bundle. A child in the stack with no inbound FK is refused everywhere; one that exists nowhere is refused by `os validate` / `os build` (bar a platform or sibling-artifact name) and by a metadata write naming no package (one into a package is stored, placing nothing). diff --git a/skills/objectstack-i18n/SKILL.md b/skills/objectstack-i18n/SKILL.md index 7e8df630000..0e1079e2ccf 100644 --- a/skills/objectstack-i18n/SKILL.md +++ b/skills/objectstack-i18n/SKILL.md @@ -57,7 +57,7 @@ The canonical authoring path: one `TranslationData` per locale, assembled with ```typescript -// src/translations/en.ts — one TranslationData per locale +// src/translations/en.ts import { defineStack, defineTranslationBundle } from '@objectstack/spec'; import type { TranslationData } from '@objectstack/spec/system'; @@ -125,13 +125,13 @@ const zhCN: TranslationData = { }, }; -// src/translations/index.ts — assemble the locales into one bundle… +// src/translations/index.ts export const TodoTranslations = defineTranslationBundle({ en, 'zh-CN': zhCN, }); -// objectstack.config.ts — …and register it on the stack +// objectstack.config.ts export default defineStack({ i18n: { defaultLocale: 'en', supportedLocales: ['en', 'zh-CN'] }, translations: [TodoTranslations], @@ -153,10 +153,10 @@ All translatable content for a single object is aggregated under | `label` / `pluralLabel` / `description` | Object-level text (every key optional) | | `fields.{field_name}` | `label`, `help`, `placeholder`, `options` (option value → label), `inlineTitle` (the heading of the inline child grid a `master_detail` field draws on its parent's form — the field lives on the child object, so the key is the child's; untranslated it keeps its authored text, never the child's plural label), `relatedListTitle` (likewise, the title of the related list a `lookup` or `master_detail` field draws on its parent's record page) per field | | `_views.{view_name}` | `label`, `description`, `title` (a form view's own heading — only a form that authors one is translated; a list view has none), `submitBehavior.title` / `submitBehavior.message` (the thank-you panel of a form whose `submitBehavior` is `kind: 'thank-you'`; only the copy the form authors is translated, and the other kinds carry none), `emptyState.title` / `emptyState.message`, `bulkActions.{def_name}` (`label`, `confirmText`, `confirmLabel`, `params`) | -| `_actions.{action_name}` | `label`, `description`, `confirmText`, `submitText` (the param dialog's button verb — only under an action that declares `params`), `cancelText` (the dismiss button of the confirm or param dialog — only under an action that declares `confirmText` or a non-empty `params`), `successMessage`, `disabledReason` (the sentence a greyed action shows; absent keeps the console's default), `params.{param_name}` (and `.options.{value}` beneath it — an option's stored `value` in that param's inline `options`), `outcomeMessages.{outcome}` (an outcome the action's own `outcomeMessages` declares), `resultDialog.title` / `.description` / `.acknowledge` (only under an action that declares a `resultDialog`), `resultDialog.fields.{path}` (the literal `path` of a field in `resultDialog.fields[]`, dots included — `client.secret` is one key), `preflight.fields.{path}` (only under an action that declares `preflight`: a field's literal `path` in its `preflight.fields[]`, its value a plain string as under `resultDialog.fields`), `resultDialog.columns.{path}.{column_path}` / `preflight.columns.{path}.{column_path}` (a table's column headers, beside `fields`: the literal `path` of a `format: 'table'` field, then of one of its `columns[]`, each a plain string; `defineTranslationBundle` refuses any other key under `preflight`, a `title` included); the same keys hold under `globalActions.{action_name}` | +| `_actions.{action_name}` | `label`, `description`, `confirmText`, `submitText` (the param dialog's button verb — only under an action that declares a non-empty `params`), `cancelText` (the dismiss button of the confirm or param dialog — only under an action that declares `confirmText` or a non-empty `params`), `successMessage`, `disabledReason` (the sentence a greyed action shows; absent keeps the console's default), `params.{param_name}` (and `.options.{value}` beneath it — an option's stored `value` in that param's inline `options`), `outcomeMessages.{outcome}` (an outcome the action's own `outcomeMessages` declares), `resultDialog.title` / `.description` / `.acknowledge` (only under an action that declares a `resultDialog`), `resultDialog.fields.{path}` (the literal `path` of a field in `resultDialog.fields[]`, dots included — `client.secret` is one key), `preflight.fields.{path}` (only under an action that declares `preflight`: a field's literal `path` in its `preflight.fields[]`, its value a plain string as under `resultDialog.fields`), `resultDialog.columns.{path}.{column_path}` / `preflight.columns.{path}.{column_path}` (a table's column headers, beside `fields`: the literal `path` of a `format: 'table'` field, then of one of its `columns[]`, each a plain string; `defineTranslationBundle` refuses any other key under `preflight`, a `title` included); the same keys hold under `globalActions.{action_name}` | | `_sections.{section_name}` | Form section `label`, `description`; `fields.{field_name}` — the `label`, `placeholder`, `helpText` an entry overrides for that form alone (`helpText` here, `help` under `fields.{field_name}` above: each spells what its source does) | | `_tabs.{tab_name}` | Filter-preset tab `label` (`ViewTabSchema.name`) | -| `_relatedLists.{list}` | `label` of an object-form `relatedLists` entry on this (parent) object, by its literal `list` (`event.related_to` is one key); an entry with no `label` has no key and keeps the child field's `relatedListTitle`, else the child's plural label. Where the paired `.custom` package's `relatedLists` (**objectstack-data**) re-states the entry without a `label`, or hides it, `os validate` refuses the key: drop it, or re-state the entry, shown, with the owner's own `label`. Spelled `relatedLists`, the group is refused, naming this one | +| `_relatedLists.{list}` | `label` of an object-form `relatedLists` entry on this (parent) object, by its literal `list` (`event.related_to` is one key); an entry with no `label` has no key and keeps the child field's `relatedListTitle`, else the child's plural label. Where the paired `.custom` package's `relatedLists` (**objectstack-data**) re-states the entry without a `label`, or hides it, `os validate` refuses the key: drop it, or re-state the entry, shown, with a `label`: the owner's own keeps its translation, any other reads this key from the `.custom` package's own bundle (`os i18n check` expects it). Spelled `relatedLists`, the group is refused, naming this one | | `_milestones.{field}.{value}` | `summary`, the timeline sentence of the `activityMilestones` entry firing on that field and value, same `{field}` tokens: composed at read time in the reader's language (a select token as its option label), stored row unchanged, redacted as the stored sentence is | | `_validations.{rule_name}` | `message` only — the sentence a rejected write returns (replaces the retired `validationMessages`) | | `_actions.{action_name}.refusals.{CODE}` | `message`, and `reasons.{reason}.message` per declared reason — the sentences of the action's `refusals` catalogue (**objectstack-ui** → Actions), for a code and reason it declares (any other is `translation-target-unknown`); the same under `globalActions.{action_name}` | @@ -171,7 +171,10 @@ spine, by `Book.name`: `books.{book}.label` / `.description`, and `groups.{group 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), `mappings` (an import mapping's `label` by its `name`: -`mappings.{mapping}.label`), `metadataForms`, `settingsCommon`; `reports`, `positions` and +`mappings.{mapping}.label`), `packages` (`name` / `description` by `manifest.id`, the dotted id one +key: `packages: { 'com.acme.crm': { name: '客户关系' } }`; a locale with no row shows +`manifest.name`, and `os lint` warns `i18n/missing-package` (`os i18n check` lists the key) +until that package's own bundle carries it), `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 @@ -225,14 +228,9 @@ parse, ship, and resolve to nothing. is an **error** and fails the run; `translation-option-key-unknown` is a warning. A key naming an object, field, view, tab, action, param, section, validation rule, app, nav item, dashboard, widget or flow screen that does not exist is listed alongside the names -that do. Six more shapes under an action entry are the error: an outcome the action does -not declare in `outcomeMessages`; a `resultDialog.fields` or `preflight.fields` path it does -not declare; a `columns` key whose field path is no declared `format: 'table'` field, or -whose column path that field's `columns[]` does not list; -`resultDialog` `title` / `description` / `acknowledge` under an action that declares no -`resultDialog`; `submitText` under an action with no non-empty `params`; and `cancelText` -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 +that do. The same error: a key the `_actions` row above ties to something the action does not declare +(an outcome, a dialog field or column path, `resultDialog` copy, `submitText`, `cancelText`) — +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.