feat/df-1065: Welsh translation for plugin#436
Open
jbarnsley10 wants to merge 95 commits into
Open
Conversation
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.
…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.
…-engine-plugin into feature/i18n-linting
…-engine-plugin into feature/i18n-linting
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Proposed change
Welsh translation for plugin
Jira ticket: DF-1065
Type of change
Checklist
README.mdanddocs/*(where appropriate, e.g. new features).npm run test).npm run lint).npm run format).