Resolve an option's user-visible label. * Accepts a bare string or a `{label, label_code?}` dict; returns null * if no usable label can be produced. The `label_code` is a backend i18n * key consumed by `translateBackend`; we don't keep it on the normalized * output because nothing downstream
(raw: any)
| 16 | * key consumed by `translateBackend`; we don't keep it on the normalized |
| 17 | * output because nothing downstream reads it. */ |
| 18 | function normalizeOption(raw: any): ClarificationOption | null { |
| 19 | if (typeof raw === 'string') { |
| 20 | const label = raw.trim(); |
| 21 | return label ? { label } : null; |
| 22 | } |
| 23 | if (!raw || typeof raw !== 'object') return null; |
| 24 | |
| 25 | const label = translateBackend( |
| 26 | String(raw.label || ''), |
| 27 | typeof raw.label_code === 'string' ? raw.label_code : undefined, |
| 28 | ).trim(); |
| 29 | return label ? { label } : null; |
| 30 | } |
| 31 | |
| 32 | /** Resolve a question's translated text + its options. The `*_code` / |
| 33 | * `text_params` keys are i18n inputs only — they're not preserved on the |
no test coverage detected