Repository navigation
Commit 63e3873
feat(spec)!: a single-word language name (Chinese, English, Japanese) is refused as a locale (#26770)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBP2wUZwvu3z6Y7h5975xXQ2)_
Fixes #26463
Clause-②: no (narrowing)
Metadata-protocol: narrowed
Skills-docs: none — `content/docs/ui/translations.mdx` and
`content/docs/protocol/kernel/i18n-standard.mdx` already say a language
name is refused (this diff makes that sentence true), and
`skills/objectstack-i18n/SKILL.md` already teaches tag-shaped codes only
(`en`, `en-US`, `zh-CN`, `pt-BR`); nothing taught there changes
## 维护者速读
- 改了什么:locale 的主语言子标签从 2–8 个字母收紧为 2–3 个字母,`Chinese`、`English`、`Japanese`
这类单词语言名现在被拒;spec、`sys_user.locale` 列规则、通知读侧三处同一字符串同步改。
- 为什么改:作者写 `locale: 'Chinese'` 能保存成功,但没有会话会请求这个 locale,译文永远不显示;拒收文案和
#25822 的 changeset 早已承诺「语言名会被拒」。
- 风险与回滚:已存为 `Chinese` 之类的翻译行或用户 locale,解析时会被拒(存量行照常加载并由 `os migrate meta
--stored` 列为 TODO);回滚即还原这三处正则。
-
先看:`packages/spec/src/system/translation.zod.ts`(正则与拒收文案)、`packages/platform-objects/src/identity/sys-user.object.ts`(列规则)、`packages/services/service-messaging/src/recipient-locale.ts`(读侧副本与
`null` 说明)。
- 两分钟验证:`pnpm --filter @objectstack/spec exec vitest run
src/system/translation.test.ts`,预期 `Chinese`/`English`/`Japanese`
三行拒收、`en`/`zh-CN`/`zh-Hans-CN`/`es-419` 通过。
- 需要你做的:无,席位落地。
## What changes
`LOCALE_TAG_SHAPE` accepted a 2–8 letter language subtag, so any single
English word of that length passed as a locale, though
`LOCALE_TAG_REFUSAL` and the #25822 changeset both say a language name
is refused. The primary subtag is now 2–3 letters, the ISO 639 codes
every tag in use starts with: BCP-47 reserves 4 letters and registers no
5–8 letter language. Hyphen subtags, `zh-Hans-CN`, `es-419`, `yue-HK`
and case folding are unchanged.
The one shape lives in three places, and all three move in the same
commit, still byte-identical:
| Copy | Role | Edit |
|---|---|---|
| `packages/spec/src/system/translation.zod.ts` `LOCALE_TAG_SHAPE` |
`LocaleSchema`: translation item `locale`, bundle keys, `i18n.*`
locales, seed `locale` | pattern; docblock and refusal text re-read so
each sentence is true (the refusal now names `Chinese` and says write
the tag, not the name) |
| `packages/platform-objects/src/identity/sys-user.object.ts`
`SYS_USER_LOCALE_TAG_PATTERN` | the `locale_bcp47_shape` rule on
`sys_user.locale` | pattern and docblock |
| `packages/services/service-messaging/src/recipient-locale.ts`
`LOCALE_TAG_SHAPE` | read side for a recipient's notification locale |
pattern; docblock: `null` is now shape-refused on both sides,
`NOTHING_LITERALS` stays as the read side's own floor |
Also: the 18.x D3 entry `translation-locale-non-tag-refused` described
the replacement as "a 2-8 letter language subtag"; this diff made that
false, so it now reads 2-3 (one word). Its conversion already judges
with `LocaleSchema`, so a stored item under `Chinese` is now listed as a
TODO with no further change.
ADR-0087 disposition: `not-required (already-registered
translation-locale-non-tag-refused)` in the changeset. The D3 entry
already prescribes rewriting a language name by hand; this diff narrows
the same shape.
### Copies of the pattern deliberately not moved
-
`packages/plugins/plugin-hono-server/src/current-user-endpoints-localization.test.ts:69`:
a fixture rule. Its own docblock says what is under test is that the
endpoint evaluates whatever rule the registry declares, and none of its
13 cases depends on a 4–8 letter subtag (all 13 pass unchanged). Outside
the claim's file surface.
- `ui/packages/i18n/src/provider.tsx:224`: the no-`Intl` fallback of
`isWellFormedLanguageTag`. The main branch is
`Intl.getCanonicalLocales`, which accepts `Chinese`; narrowing only the
fallback would make the two branches disagree. It reads a UI language
preference, not stored metadata.
-
`ui/packages/app-shell/src/views/metadata-admin/previews/doc-draft.ts:28`:
add-locale input hygiene for a doc's `translations` map, which the spec
keys by any string. A different contract, outside the claim's file
surface.
## Tests
- `packages/spec/src/system/translation.test.ts`: refusal rows
`Chinese`, `English`, `Japanese`, `chinese-CN`, `null` (each an
`invalid_format` issue whose message names the shape and the release);
controls `en`, `zh-CN`, `zh-Hans-CN`, `es-419`, `yue-HK`, `zh-cn`
accepted; the card's reproduction at the item door (`locale: 'Chinese'`
refused at `locale` only) and a `Chinese` bundle key refused.
-
`packages/plugins/plugin-auth/src/sys-user-locale-write-contract.test.ts`:
the shape-not-membership pin is rewritten. `Japanese` is now refused by
the column (`VALIDATION_FAILED`), and a well-formed tag nothing ships
(`tlh-QQ`) is still accepted, which keeps the pin about shape, not
membership.
-
`packages/services/service-messaging/src/recipient-locale-shape-parity.test.ts`:
source equality unchanged; behavioural rows gain `Chinese`, `Japanese`,
`null`; the `null` case now pins that both sides refuse it by shape and
the read side refuses it anyway.
## Acceptance notes
- Precedent #25983 declared `Clause-②: no (narrowing)`; this card
follows it (the claim says the same).
- `test:repo` (vitest `repo` project) was not run locally: the diff
edits none of its tests and the derived list does not name it; CI `Test
Core` runs it.
## Verification
All readings on head `84506a0c` (this branch merged with `main`
`5cc31c78`) unless noted.
<details><summary>Tests and typecheck</summary>
- Before the merge, on `ee3058c2`: `pnpm --filter @objectstack/spec
test` 731 files, 21928 passed, 1 todo; `@objectstack/service-messaging
test` 61 files, 732 passed; `@objectstack/plugin-auth test` 198 files,
3780 passed, 10 skipped; `@objectstack/platform-objects test` 96 files,
1361 passed; `plugin-hono-server`
`src/current-user-endpoints-localization.test.ts` 13 passed.
- `typecheck` exit 0 for spec, platform-objects, service-messaging and
plugin-auth (plugin-auth after a full build; its examples leg needs its
own dist).
- After the merge, on `84506a0c`: `src/system/translation.test.ts` 189
passed; platform-objects 96 files, 1361 passed;
`recipient-locale-shape-parity.test.ts` 19 passed;
`sys-user-locale-write-contract.test.ts` 24 passed.
- `pnpm build`: 116 of 116 tasks; `pnpm --filter @objectstack/spec
check:generated`: all 14 generated artifacts up to date (no regeneration
commit needed).
</details>
<details><summary>Ablation (one-time, not kept)</summary>
`node scripts/ablation-replace.mjs` put the spec pattern back to the 2–8
letter subtag (anchor hit 1 to 0, blob `fa4a2333` to `1108375e`) and ran
`src/system/translation.test.ts`: 6 failed, 183 passed. The red rows are
`Chinese`, `English`, `Japanese`, `chinese-CN`, `null` and the door test
that carries the card's reproduction. Restored: blob equals HEAD
(`fa4a2333`) and `git diff HEAD` is empty. The test imports `src`, so no
build leg applies.
</details>
<details><summary>Derived gates</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 87 families on `84506a0c`. Each was
run and recorded as `CMD :: exit N`: all 87 exit 0. `--ran`
reconciliation: 87 derived, 87 run, 0 NOT-MEASURED, 0 UNRUN.
`check-adr-0087-registration --base origin/main`: one declared-breaking
changeset, disposition `not-required (already-registered)`.
</details>
<details><summary>Dogfood battery</summary>
`pnpm --filter @objectstack/dogfood test` under the verify lock, after a
full build. On `84506a0c`: VERDICT command-exit 0, 302 files passed and
3 skipped (305), 2505 tests passed and 20 skipped (2525). Also on the
pre-merge head `32f73697`: the same counts.
</details>
`main` gained six more commits after the merge (none touch the eight
files here); CI judges the merge ref.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01WGufziYkxRFm6oPR7CmuDg)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent b198f91 commit 63e3873
8 files changed
Lines changed: 97 additions & 49 deletions
File tree
- .changeset
- packages
- platform-objects/src/identity
- plugins/plugin-auth/src
- services/service-messaging/src
- spec/src
- migrations/entries/semantic
- system
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
12 | 18 | | |
13 | 19 | | |
14 | 20 | | |
| |||
30 | 36 | | |
31 | 37 | | |
32 | 38 | | |
33 | | - | |
| 39 | + | |
34 | 40 | | |
35 | 41 | | |
36 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
216 | 218 | | |
217 | 219 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
83 | 81 | | |
84 | 82 | | |
85 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
| 115 | + | |
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
57 | 62 | | |
58 | 63 | | |
59 | 64 | | |
| |||
71 | 76 | | |
72 | 77 | | |
73 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
74 | 83 | | |
75 | 84 | | |
76 | 85 | | |
| |||
79 | 88 | | |
80 | 89 | | |
81 | 90 | | |
| 91 | + | |
82 | 92 | | |
83 | 93 | | |
84 | 94 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
30 | 34 | | |
31 | | - | |
| 35 | + | |
32 | 36 | | |
33 | 37 | | |
34 | | - | |
| 38 | + | |
35 | 39 | | |
36 | | - | |
37 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
38 | 43 | | |
39 | 44 | | |
40 | 45 | | |
| |||
0 commit comments