Skip to content

feat/df-1065: Welsh translation for plugin#436

Open
jbarnsley10 wants to merge 95 commits into
mainfrom
feature/i18n-linting
Open

feat/df-1065: Welsh translation for plugin#436
jbarnsley10 wants to merge 95 commits into
mainfrom
feature/i18n-linting

Conversation

@jbarnsley10

@jbarnsley10 jbarnsley10 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Proposed change

Welsh translation for plugin

Jira ticket: DF-1065

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

Adds buildValidationMessages(t) — a factory that accepts a language-bound
translation function and returns a set of Joi message templates (JoiExpressions
for lowerFirst-containing strings, plain template strings for the rest).

Also adds require('@defra/forms-model') to jest.setup.cjs to align Joi's
internal Symbol state across the babel-jest ESM/CJS module boundary; without
this, JoiExpression objects fail Template.isTemplate() checks inside Joi's
.messages() method when resetModules: true clears the registry between tests.
…key, lang)

Remove the lang parameter from getValidationConfig/getErrorTemplates in
NationalGridFieldNumberField and OsGridRefField; fix LocationFieldBase
constructor call that was passing model.language as an argument.
Static getAllPossibleErrors() now constructs the result directly using
the module-level t() at en-GB, matching the pattern used by
EastingNorthingField.
…l.language)

Remove free t() import from all five page controllers; replace every
t(key, lang/this.model.language, opts) call with this.model.t(key, opts).
Includes getBackLink lang var removal and all RepeatPageController
list-summary translation calls.
The two inline controller.model mocks in the dispatcher error tests
were missing the t() method after PaymentField.ts was updated to call
model.t() instead of the free t(key, lang) function.
Adds x-pirate locale (arrr), registers it in i18next, and wires up
simple-form-pirate.yaml in localFormsService. Visit /simple-form-pirate
to experience the high seas.
Apply pirate flavour to every remaining bland key — date field labels,
lat/long errors, address fields, button labels, repeater actions, and
payment strings. Comedy matters everywhere.
alexluckett and others added 29 commits April 29, 2026 16:23
…rs in correct language

UkAddressField.dispatcher now resolves the per-request language via getPluginOptions
and includes it in the initial session data. The postcode lookup models already
read session.initial.language — it was simply never being set.
…ection titles

YesNo list items now store i18n key constants ('components.yesNoField.yes') instead
of construction-time English strings. ListFormComponent.getViewModel and
getDisplayStringFromFormValue resolve them via tContent/tPlugin at render time.
getAnswerMarkdown also resolves item text via translator.

DeclarationField.getValidationMessagesOverride returns Welsh declarationRequired
expression; ComponentCollection.validate now also applies message overrides for
non-composite fields (same pattern as composite sub-fields).

SummaryViewModel.summaryDetails resolves section titles via tContent.

stubTranslator.tContent now resolves raw values via resolveKey('en-GB') so i18n
key constants (e.g. 'components.yesNoField.yes') return 'Yes' in tests.
…ate YesNo validation

resolveContent now calls t(raw) as fallback when a GUID entity has no form
translation, so plugin key constants like 'components.yesNoField.yes' stored
as list item text are resolved to 'Ie'/'Na' etc. rather than returned verbatim.

YesNoField.getValidationMessagesOverride applies the per-request Welsh
selectYesNoRequired template at validation time, replacing the English message
baked into the schema at construction time.
…introduce RenderContext for components

Move the getLanguage/createTranslator boilerplate into a protected
PageController.getTranslator(request) helper so new page controllers
inherit it without any i18n knowledge.

Replace the four-positional-param getViewModel signature on all form
components with a single RenderContext object { payload, errors,
translator, isForceAccess? } so future context additions (permissions,
feature flags, etc.) don't require touching every component signature.
…iminate fallback patterns

translator is now required on getDisplayStringFromState, getDisplayStringFromFormValue,
getViewErrors, getAnswer, and getAnswerMarkdown. All callers either thread a per-request
translator or construct one via model.createTranslator() which defaults to en-GB.

Removes all translator?.t ?? tPlugin() fallback patterns — English now lives only in
en-GB.json. GeospatialField, FileUploadField, UkAddressField, CheckboxesField,
DeclarationField, and ListFormComponent cleaned up accordingly. getErrors retains
optional translator since it is called from validation paths without a request context.
@sonarqubecloud

sonarqubecloud Bot commented Jul 1, 2026

Copy link
Copy Markdown

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