Tell processors when forms have been submitted in Welsh#1855
Tell processors when forms have been submitted in Welsh#1855thomasiles merged 12 commits intomainfrom
Conversation
3a84895 to
e4ac9e4
Compare
DavidBiddle
left a comment
There was a problem hiding this comment.
Really nice and readable PR, and well broken up 🎉
All works for me when testing locally - if at least one answer is entered on a Welsh screen, the email contains the line about Welsh and the JSON/CSV include the welshlanguage flag.
e4ac9e4 to
2a2a38b
Compare
DavidBiddle
left a comment
There was a problem hiding this comment.
Code looks good 🎉
I've tested locally and can see what I think is the correct behaviour:
- monolingual form:
- no message in the email text
- no
languagefield in the JSON or CSV
- bilingual form answered entirely on the English routes:
- no message in the email text
languageset toenin the JSON and CSV
- bilingual form answered partly on the Welsh routes:
- message in the email text
languageset tocyin the JSON and CSV
Add a new column, submission_locale, to the submissions table. We will use this to store the language the form was submitted in.
We are going to store the locales used when filling in a form in the session answer store. They will be stored in an array under the key `locales`, form_id, in the store. We clear the locales when the form is submitted at the same time we clear the answers.
We add a method which will decide the locale of a submission. We choose based on the locale the filler was using when submitting an answer. If they submitted any answer in Welsh, we choose :cy. Otherwise we choose :en.
The S3 submission service needs to know the locale of the submission to be able to generate the CSV and JSON files. We pass the submission_locale decided by the form submission_service to the S3 submission service.
When we create a Submission, which is used to store a submission for delivery by email, we need to know the locale of the submission. This commit adds the decided submission locale to the Submission created when the form is submitted.
We add a language field to the end of the submission CSV. We change the CSV generator to use the submission locale and pass in the value when generating the CSV for S3 and SES.
Add a language property to the JSON submission. We add language to our JSON schema or at least the version we keep in this repository for testing. JSON
When a form is submitted in Welsh, we include a message in the email to inform the processor.
The CSV generator used to take submission_locale as an argument, and always include it in the CSV in the language field. Now, only submissions for forms with Welsh will have language set to en or cy. This means all current forms won't include a language field unless they have a Welsh translation added. When the CSV is generated the language field will be set to nil. The argument name has been changed to language as it's more direct and shows what's being set in the CSV.
The JSON generator used to take submission_locale as an argument, and always include it in the JSON. Now, only submissions for forms with Welsh will have language set to en or cy. This means all current forms won't include a language field unless they have a Welsh translation added. When the JSON is generated the language field will be set to nil and the field won't be included. The argument name has been changed to language as it's more direct and shows what's being set in the JSON.
We change the submission services which call the CSV and JSON generators to pass the language instead of locale. This allows us to decide whether to include language, as taken from submission locale or pass nil to not include it at all. Only forms which have more than one language, currently only Welsh forms, will have language set.
We are not updating the JSON schema for submissions. So the changes we made to this test fixture are no longer valid. We'll update the schema here and the one in the product pages properly when we have a process for doing so.
38358c4 to
6fe0262
Compare
|
|
🎉 A review copy of this PR has been deployed! It is made of up two components Important Not all of the functionality of forms-runner is present in review apps. You should use the full dev environment to test the functionality which is disabled here. It may take 5 minutes or so for the application to be fully deployed and working. If it still isn't ready For the sign in details and more information, see the review apps wiki page. |



Add language to submission email, json, and CSV
Important
I've added some commits to this since it was reviewed to make the 'language' field in CSV and JSON submissions only show when the form has a welsh version.
Trello card: https://trello.com/c/uTDx5owN/2761-needed-before-launch-update-form-submission-templates-for-welsh-forms
This PR adds:
The Language fields in the CSV and JSON appear for every submission, English and Welsh. The message in the submission email only shows in Welsh submissions.
To decide if a submission was in Welsh, we check if any questions have been answered in the Welsh locale. This is a simple test which captures how many teams deal with Welsh submissions in their current services. It will probably be refined as we learn more about how processors work with Welsh forms.
Changing session and submission code can break fillers half-way through a session. I've tried to avoid this by making the session code and submission_locale methods work even when they don't have any values set. I've also tested email and s3 submissions in dev to make sure nothing has broken.
The JSON schema kept in the product pages needs to be updated when this is released. I'll create a PR when this one has passed review to update it.
How it looks in the Email
The CSV
The JSON
{ "$schema": "https://dev.forms.service.gov.uk/json-submissions/v1/schema", "form_name": "a test welsh form", "submission_reference": "CV3KS2C3", "submitted_at": "2026-01-22T17:01:10.625Z", "language": "cy", "answers": [ { "question_id": "MgMQgZtq", "question_text": "What's the highest number you can count to?", "answer_text": "123" }, { "question_id": "ehEDgsgq", "question_text": "Whats the next number after that?", "answer_text": "234" } ] }Things to consider when reviewing