Skip to content

feat/df-1225: Translates error description if applicable#441

Merged
jbarnsley10 merged 5 commits into
mainfrom
feat/df-1225-error-description
Jul 23, 2026
Merged

feat/df-1225: Translates error description if applicable#441
jbarnsley10 merged 5 commits into
mainfrom
feat/df-1225-error-description

Conversation

@jbarnsley10

@jbarnsley10 jbarnsley10 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Proposed change

Error description can be used to override error messages (whereas shortDescription is always used for Check Your Answers).
Handles translation of errorDescription for errors, if necessary

NOTE - I may have missed other areas where error description should override. Please check this PR thoroughly

Jira ticket: DF-1225

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Misc. (documentation, build updates, etc)

Checklist

  • You have executed this code locally and it performs as expected.
  • You have added tests to verify your code works.
  • You have added code comments and JSDoc, where appropriate.
  • There is no commented-out code.
  • You have added developer docs in README.md and docs/* (where appropriate, e.g. new features).
  • The tests are passing (npm run test).
  • The linting checks are passing (npm run lint).
  • The code has been formatted (npm run format).

Comment on lines +311 to +315
const fieldAsComponentDef = field as unknown as ComponentDef
const translatedLabel =
translator.tComponent(
field as unknown as ComponentDef,
'shortDescription'
) ||
translator.tComponent(field as unknown as ComponentDef, 'title')
translator.tComponent(fieldAsComponentDef, 'errorDescription') ||
translator.tComponent(fieldAsComponentDef, 'shortDescription') ||
translator.tComponent(fieldAsComponentDef, 'title')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same bug as we previously discussed, field is not a componentdef. possibly this.def?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks. It works because it just needs the component id, but I will correct

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not possible to directly convert a Field to a ComponentDef. this.def is never saved in the ComponentBase, only certain properties from def.
Therefore, as the translator only needs the id, all I can really do is something liek this:

const componentDefWithId = { id: field.id } as unknown as ComponentDef
          const translatedLabel =
            translator.tComponent(componentDefWithId, 'errorDescription') ||
            translator.tComponent(componentDefWithId, 'shortDescription') ||
            translator.tComponent(componentDefWithId, 'title')

What do you think?

@jbarnsley10
jbarnsley10 enabled auto-merge July 23, 2026 10:34
@sonarqubecloud

Copy link
Copy Markdown

@jbarnsley10
jbarnsley10 merged commit 5cab775 into main Jul 23, 2026
24 checks passed
@jbarnsley10
jbarnsley10 deleted the feat/df-1225-error-description branch July 23, 2026 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants