diff --git a/src/server/plugins/engine/components/EastingNorthingField.test.ts b/src/server/plugins/engine/components/EastingNorthingField.test.ts index 839ac106c..04b467cd4 100644 --- a/src/server/plugins/engine/components/EastingNorthingField.test.ts +++ b/src/server/plugins/engine/components/EastingNorthingField.test.ts @@ -890,7 +890,7 @@ describe('EastingNorthingField', () => { northing: 315469 } - const mockT = jest.fn().mockReturnValue('translated country error') + const mockT = jest.fn().mockReturnValue('translated country') const mockTranslator = { ...stubTranslator, t: mockT } const result = collection.validate(getFormData(invalidSingleState)) @@ -905,12 +905,12 @@ describe('EastingNorthingField', () => { expect(mockT).toHaveBeenCalledWith( 'components.eastingNorthingField.wrongCountry', - { country: 'Scotland' } + { country: 'translated country' } ) expect(viewErrors).toEqual([ expect.objectContaining({ href: '#myComponent', - text: 'translated country error' + text: 'translated country' }) ]) }) diff --git a/src/server/plugins/engine/components/EastingNorthingField.ts b/src/server/plugins/engine/components/EastingNorthingField.ts index 9f2f8083b..d7c67e5a8 100644 --- a/src/server/plugins/engine/components/EastingNorthingField.ts +++ b/src/server/plugins/engine/components/EastingNorthingField.ts @@ -187,7 +187,7 @@ export class EastingNorthingField extends FormComponent { if (err.context?.country) { err.text = translator.t( 'components.eastingNorthingField.wrongCountry', - { country: err.context.country } + { country: translator.t(`common.${err.context.country}`) } ) } }) diff --git a/src/server/plugins/engine/components/GeospatialField.ts b/src/server/plugins/engine/components/GeospatialField.ts index c60a2180f..78a00ebf8 100644 --- a/src/server/plugins/engine/components/GeospatialField.ts +++ b/src/server/plugins/engine/components/GeospatialField.ts @@ -127,9 +127,7 @@ export class GeospatialField extends FormComponent { 'components.geospatialField.validation.wrongCountry', { count: Number(err.path[1]) + 1, - country: translator.t( - `common.${(err.context.country as string).toLowerCase()}` - ) + country: translator.t(`common.${err.context.country}`) } ) } diff --git a/src/server/plugins/engine/components/helpers/geospatial.ts b/src/server/plugins/engine/components/helpers/geospatial.ts index 8bb901ebb..36f6648f2 100644 --- a/src/server/plugins/engine/components/helpers/geospatial.ts +++ b/src/server/plugins/engine/components/helpers/geospatial.ts @@ -1,5 +1,4 @@ import { - GeospatialFieldOptionsCountryEnum, type GeospatialFieldComponent, type GeospatialFieldOptionsCountry } from '@defra/forms-model' @@ -20,13 +19,6 @@ import { } from '~/src/server/plugins/engine/types.js' import { countries } from '~/src/server/plugins/map/routes/index.js' -const countriesDesc: Record = { - [GeospatialFieldOptionsCountryEnum.England]: 'England', - [GeospatialFieldOptionsCountryEnum.NorthernIreland]: 'Northern Ireland', - [GeospatialFieldOptionsCountryEnum.Scotland]: 'Scotland', - [GeospatialFieldOptionsCountryEnum.Wales]: 'Wales' -} - const Joi = JoiBase.extend({ type: 'array', base: JoiBase.array(), @@ -161,7 +153,7 @@ export function getGeospatialSchema( if (!result) { return helpers.error('any.custom', { - country: countriesDesc[country as GeospatialFieldOptionsCountryEnum] + country }) } @@ -212,7 +204,7 @@ export function getEastingNorthingCountryValidator( return helpers.error( 'any.custom', { - country: countriesDesc[country as GeospatialFieldOptionsCountryEnum] + country }, { path: [field.name] } ) diff --git a/src/server/plugins/engine/i18n/translations/cy.json b/src/server/plugins/engine/i18n/translations/cy.json index 7496f4545..434bdebda 100644 --- a/src/server/plugins/engine/i18n/translations/cy.json +++ b/src/server/plugins/engine/i18n/translations/cy.json @@ -44,7 +44,7 @@ "and": "a", "england": "Lloegr", "wales": "Cymru", - "northernIreland": "Gogledd Iwerddon", + "northern-ireland": "Gogledd Iwerddon", "scotland": "Yr Alban", "sendFeedback": "Anfon adborth" }, diff --git a/src/server/plugins/engine/i18n/translations/en-GB.json b/src/server/plugins/engine/i18n/translations/en-GB.json index 3fbf31ca8..d0fdda945 100644 --- a/src/server/plugins/engine/i18n/translations/en-GB.json +++ b/src/server/plugins/engine/i18n/translations/en-GB.json @@ -44,7 +44,7 @@ "and": "and", "england": "England", "wales": "Wales", - "northernIreland": "Northern Ireland", + "northern-ireland": "Northern Ireland", "scotland": "Scotland", "sendFeedback": "Send feedback" },