@@ -36,6 +36,15 @@ export interface Scopable {
3636 scope : string ;
3737}
3838
39+ /**
40+ * Interface for describing an UI schema element that can provide an internationalization base key.
41+ * If defined, this key is suffixed to derive applicable message keys for the UI schema element.
42+ * For example, such suffixes are `.label` or `.description` to derive the corresponding message keys for a control element.
43+ */
44+ export interface Internationalizable {
45+ i18n ?: string ;
46+ }
47+
3948/**
4049 * A rule that may be attached to any UI schema element.
4150 */
@@ -207,17 +216,12 @@ export interface LabelElement extends UISchemaElement {
207216 * A control element. The scope property of the control determines
208217 * to which part of the schema the control should be bound.
209218 */
210- export interface ControlElement extends UISchemaElement , Scopable {
219+ export interface ControlElement extends UISchemaElement , Scopable , Internationalizable {
211220 type : 'Control' ;
212221 /**
213222 * An optional label that will be associated with the control
214223 */
215224 label ?: string | boolean | LabelDescription ;
216- /**
217- * The i18n key for the control. It is used to identify the string that needs to be translated.
218- * It is suffixed with `.label`, `.description` and `.error.<keyword>` to derive the corresponding message keys for the control.
219- */
220- i18n ?: string ;
221225}
222226
223227/**
@@ -249,8 +253,9 @@ export interface Categorization extends UISchemaElement {
249253 elements : ( Category | Categorization ) [ ] ;
250254}
251255
252- export const isControlElement = ( element : UISchemaElement ) : element is ControlElement =>
253- element . type === 'Control' ;
256+ export const isInternationalized = ( element : unknown ) : element is Required < Internationalizable > => {
257+ return typeof element === 'object' && element !== null && typeof ( element as Internationalizable ) . i18n === 'string' ;
258+ }
254259
255260export const isGroup = ( layout : Layout ) : layout is GroupLayout =>
256261 layout . type === 'Group' ;
0 commit comments