@form-engine-ts/core 3.1.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -0
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -51,6 +51,31 @@ Required locales cover every source text that exists on the form, its fields, op
|
|
|
51
51
|
`{ policy: { allowedLocales, maxLocales } }` to `populateSchemaTranslations` to reject inadmissible targets before the
|
|
52
52
|
translation adapter runs.
|
|
53
53
|
|
|
54
|
+
The React builder uses canonical keys with legacy aliases when resolving UI translations:
|
|
55
|
+
|
|
56
|
+
| Canonical key | Legacy alias |
|
|
57
|
+
| --- | --- |
|
|
58
|
+
| `builder.fields.typeText` | `builder.fieldType.text` |
|
|
59
|
+
| `builder.fields.typeTextarea` | `builder.fieldType.textarea` |
|
|
60
|
+
| `builder.fields.typeNumber` | `builder.fieldType.number` |
|
|
61
|
+
| `builder.fields.typeRating` | `builder.fieldType.rating` |
|
|
62
|
+
| `builder.fields.typeRadio` | `builder.fieldType.radio` |
|
|
63
|
+
| `builder.fields.typeCheckbox` | `builder.fieldType.checkbox` |
|
|
64
|
+
| `builder.fields.typeSelect` | `builder.fieldType.select` |
|
|
65
|
+
| `builder.fields.typeMultiSelect` | `builder.fieldType.multi-select` |
|
|
66
|
+
|
|
67
|
+
Adapters should return `undefined` or `null` for missing keys so the builder can try aliases and its default catalog. For
|
|
68
|
+
example, an i18next adapter can avoid treating an unresolved key as translated:
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
const i18nextAdapter: TranslationAdapter = {
|
|
72
|
+
translate: (key, locale, params) => {
|
|
73
|
+
if (!i18n.exists(key, { lng: locale })) return undefined;
|
|
74
|
+
return i18n.t(key, { ...params, lng: locale });
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
```
|
|
78
|
+
|
|
54
79
|
Translation callbacks receive `nodeMetadata` and `existingTranslationMetadata` separately. The deprecated `metadata`
|
|
55
80
|
slot property remains an alias for `nodeMetadata` during migration.
|
|
56
81
|
|
package/dist/index.d.cts
CHANGED
|
@@ -255,7 +255,8 @@ interface FormSubmission extends ExtensibleNode {
|
|
|
255
255
|
readonly submittedAt: string;
|
|
256
256
|
}
|
|
257
257
|
interface TranslationAdapter {
|
|
258
|
-
|
|
258
|
+
/** Return null or undefined when the key cannot be resolved by the adapter. */
|
|
259
|
+
translate(key: string, locale: string, params?: Readonly<Record<string, string | number>>): string | undefined | null;
|
|
259
260
|
}
|
|
260
261
|
interface AsyncTranslationAdapter {
|
|
261
262
|
translateText(text: string, targetLocale: string, sourceLocale?: string): Promise<string>;
|
package/dist/index.d.ts
CHANGED
|
@@ -255,7 +255,8 @@ interface FormSubmission extends ExtensibleNode {
|
|
|
255
255
|
readonly submittedAt: string;
|
|
256
256
|
}
|
|
257
257
|
interface TranslationAdapter {
|
|
258
|
-
|
|
258
|
+
/** Return null or undefined when the key cannot be resolved by the adapter. */
|
|
259
|
+
translate(key: string, locale: string, params?: Readonly<Record<string, string | number>>): string | undefined | null;
|
|
259
260
|
}
|
|
260
261
|
interface AsyncTranslationAdapter {
|
|
261
262
|
translateText(text: string, targetLocale: string, sourceLocale?: string): Promise<string>;
|