Commit 59e7ecc
feat(i18n): make QualifierMessage strings translatable (#1364)
Move qualifier-message rendering fully to the theme layer so that
Docusaurus i18n can translate the human-readable constraint strings:
- "characters" (minLength / maxLength)
- "non-empty" (minLength === 1)
- "Value must match regular expression" (pattern)
Architecture:
- `getQualifierMessage` is removed from the plugin and kept only in
the theme (`docusaurus-theme-openapi-docs/src/markdown/schema.ts`),
where `translate()` is available at render time.
- `SchemaItem` now computes `qualifierMessage` from its `schema` prop
when the caller doesn't pass one explicitly, so all callers are
simplified — no more `qualifierMessage={getQualifierMessage(schema)}`
at every call site.
- Plugin `createSchema.ts` and `Schema/index.tsx` drop all
`qualifierMessage` prop passes; the theme component handles it.
- `utils.ts` `create()` skips props with `undefined` values, cleaning
up generated MDX.
- Dead code removed: `humanizeConstraints`, `humanizeNumberRange`, and
related helpers were exported but unused.
Translation IDs added:
theme.openapi.schemaItem.characters
theme.openapi.schemaItem.nonEmpty
theme.openapi.schemaItem.expression
Demo directory intentionally untouched (no locale config added).
Closes #1249. Credit: @dsuket
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 22d48e4 commit 59e7ecc
File tree
11 files changed
+39
-618
lines changed- packages
- docusaurus-plugin-openapi-docs/src
- markdown
- __snapshots__
- openapi/utils/utils
- docusaurus-theme-openapi-docs/src
- markdown
- theme
- ResponseHeaders
- SchemaItem
- Schema
11 files changed
+39
-618
lines changedLines changed: 0 additions & 100 deletions
Large diffs are not rendered by default.
Lines changed: 3 additions & 42 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
144 | 143 | | |
145 | 144 | | |
146 | 145 | | |
| |||
169 | 168 | | |
170 | 169 | | |
171 | 170 | | |
172 | | - | |
173 | 171 | | |
174 | 172 | | |
175 | 173 | | |
| |||
209 | 207 | | |
210 | 208 | | |
211 | 209 | | |
212 | | - | |
213 | 210 | | |
214 | 211 | | |
215 | 212 | | |
| |||
399 | 396 | | |
400 | 397 | | |
401 | 398 | | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | 399 | | |
409 | 400 | | |
410 | 401 | | |
| |||
545 | 536 | | |
546 | 537 | | |
547 | 538 | | |
548 | | - | |
549 | | - | |
550 | | - | |
551 | | - | |
552 | | - | |
553 | | - | |
554 | | - | |
555 | | - | |
556 | 539 | | |
557 | 540 | | |
558 | 541 | | |
| |||
727 | 710 | | |
728 | 711 | | |
729 | 712 | | |
730 | | - | |
731 | 713 | | |
732 | 714 | | |
733 | 715 | | |
| |||
738 | 720 | | |
739 | 721 | | |
740 | 722 | | |
741 | | - | |
742 | 723 | | |
743 | 724 | | |
744 | 725 | | |
| |||
823 | 804 | | |
824 | 805 | | |
825 | 806 | | |
826 | | - | |
827 | | - | |
828 | | - | |
829 | | - | |
830 | | - | |
831 | | - | |
832 | | - | |
833 | | - | |
834 | | - | |
835 | | - | |
836 | | - | |
| 807 | + | |
837 | 808 | | |
838 | 809 | | |
839 | 810 | | |
| |||
844 | 815 | | |
845 | 816 | | |
846 | 817 | | |
847 | | - | |
848 | | - | |
849 | | - | |
850 | | - | |
851 | | - | |
852 | | - | |
853 | | - | |
854 | | - | |
855 | | - | |
856 | | - | |
857 | | - | |
| 818 | + | |
858 | 819 | | |
859 | 820 | | |
860 | 821 | | |
| |||
Lines changed: 0 additions & 208 deletions
This file was deleted.
0 commit comments