Skip to content

fix/df-1065: Fixed optional + welsh yes/no#438

Merged
jbarnsley10 merged 11 commits into
mainfrom
fix/df-1065-optional-and-yes-no
Jul 20, 2026
Merged

fix/df-1065: Fixed optional + welsh yes/no#438
jbarnsley10 merged 11 commits into
mainfrom
fix/df-1065-optional-and-yes-no

Conversation

@jbarnsley10

@jbarnsley10 jbarnsley10 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Proposed change

Handles '(optional)' in page heading (compatible with translations)
Hard-codes Welsh Yes/No translation until we develop a better solution.
Handles payment description.

Jira ticket:

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).

@Scullyon Scullyon left a comment

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.

Sorry for all the comments, Jez!

I'm missing the context of why the temporary workaround is required - does it not translate in the standard way?


// The question text may have already appended 'optional' in the relevant language
const optionalAlreadyAppended = pageTitle.endsWith(
` ${t('common.optional')}`

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.

Would it be better to cache the result of t('common.optional') just above here in a variable, so that it can be used here and below?

i18nInstance.addResourceBundle(lng, 'form', resources, true, true)

// Temporary workaround - until we develop a better solution
const yesNoList = getYesNoList()

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.

The getYesNoList() is called within a loop - does it need to be called each time?

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.

Changed

i18nInstance.addResource(
lng,
'form',
`listItems.${yesNoList.items[0].id}.text`,

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.

This is positional, would it be better to do it by ID?

import { yesNoListNoItemId, yesNoListYesItemId } from '@defra/forms-model'
// ...
i18nInstance.addResource(lng, 'form', `listItems.${yesNoListYesItemId}.text`, 'Ie')
i18nInstance.addResource(lng, 'form', `listItems.${yesNoListNoItemId}.text`, 'Nage')

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.

Changed

lng,
'form',
`listItems.${yesNoList.items[1].id}.text`,
'Nage'

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.

Is it Nage or Na? Or even Naddo? Google Translate says Na for Yes/No and my favourite AI reckons it's context sensitive as to which of the three it might be 😂

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.

Yes, Alex asked his AI and the generic Yes/No was the options I've coded. It can change depending on context, hence the temporary fixed solution for now.

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.

Gemini tells me:

Welsh is famous for not having a single, universal word for "yes" or "no" because it usually repeats the verb used in the question. However, if you just need a generic, "catch-all" option for a quick message that people will understand, here is the best way to do it:
The Generic Option
Yes = Ie (pronounced ee-eh)
No = Nage (pronounced nah-geh, with a hard 'g')

Comment on lines +274 to +275
"one": "Mae gennych %{count} nod ar ôl",
"other": "Mae gennych %{count} nod ar ôl"

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.

can you just check the syntax for this? I notice in line 268 we use [[count]] whereas here we're using %{count}

Comment on lines +279 to +280
"one": "Mae gennych %{count} nod yn ormod",
"other": "Mae gennych %{count} nod yn ormod"

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.

as above

Comment thread src/server/plugins/engine/components/PaymentField.ts Outdated
@sonarqubecloud

Copy link
Copy Markdown

@jbarnsley10
jbarnsley10 merged commit b029af1 into main Jul 20, 2026
23 checks passed
@jbarnsley10
jbarnsley10 deleted the fix/df-1065-optional-and-yes-no branch July 20, 2026 10:54
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