Skip to content

Add welsh translations upload - #3087

Draft
stephencdaly wants to merge 9 commits into
mainfrom
add-welsh-translations-upload
Draft

Add welsh translations upload#3087
stephencdaly wants to merge 9 commits into
mainfrom
add-welsh-translations-upload

Conversation

@stephencdaly

@stephencdaly stephencdaly commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

What problem does this pull request solve?

Trello card: https://trello.com/c/35HPJgw3/3247-allow-uploading-a-csv-of-welsh-translations

Adds a page to upload a CSV of Welsh translations. This accepts a CSV in the same format as the downloaded CSV, and uses the content in the "Welsh content" column to populate the fields on the Welsh translation page. These translations are only saved when the translations page is submitted so we can perform individual validation on the fields and allow the user to correct any errors.

This PR does not add a link to the page to upload the translations, but it can be accessed for testing at /forms/:form_id/welsh-translation-upload.

Things that still need to be done in follow-up PRs:

  • Add more validation to the CSV when it is uploaded. We plan to validate the rows present in the CSV to ensure they match the current form to account for questions changing or being re-ordered to ensure we don't apply the translations in the wrong places.
  • Adjust the WAF rules to allow larger files to be uplaoded.
Screenshot 2026-09-04 at 11 32 30 Screenshot 2026-09-04 at 11 43 27 Screenshot 2026-09-04 at 12 41 17

Things to consider when reviewing

  • Ensure that you consider the wider context.
  • Does it work when run on your machine?
  • Is it clear what the code is doing?
  • Do the commit messages explain why the changes were made?
  • Are there all the unit tests needed?
  • Do the end to end tests need updating before these changes will pass?
  • Has all relevant documentation been updated?

@stephencdaly
stephencdaly force-pushed the add-welsh-translations-upload branch from 83cf72e to e6eb7ec Compare September 4, 2026 11:43
We will use the first column in the CSV to match translations to the
form/page attribute they are for when importing the translations from
an uploaded CSV.

Add a module to share constants/methods for generating these labels so
they can be re-used when importing to retrieve the translations from the
CSV.

Also add a column header to the first column in the CSV download so we
can more easily validate the headers.
Add a service that will validate the format of a Welsh translation CSV
and return a hash of content label to Welsh content.

We will use the output of this service to populate the fields on the
Welsh translations page with the translations from the CSV.
Add a method to the WelshTranslationInput that accepts the data
extracted from an uploaded CSV of translations and assigns value to
the inputs on the Welsh translations page.
Add an input object model for the web form for a new page to upload a
CSV of Welsh translations. This does basic validation on the file type
and size and then calls the WelshCsvImportService to parse the CSV.

We handle any exceptions thrown by WelshCsvImportService by mapping them
to appropriate errors to show in an error summary.
This page has a file upload input that allows the user to upload a CSV
of their Welsh translations. If the file is valid, the Welsh
translations page is rendered with the inputs populated from the CSV.
The Welsh is not saved until the user submits the translations page.

We run validation on the input model so that we will show an error
summary if any of the uploaded translations were invalid. For this
validation, the input is not marked as complete so it won't show
validation errors for translations that have not been filled in.
When pre-validating the fields after uploading a translation CSV, don't
validate that a radio has been selected for whether to mark the step as
complete.

The user will still have to select an option before they can submit
the translation page after it has been populated with translations from
the CSV.
Show a success banner when rending the translations page after the CSV
of Welsh translations has been uploaded.
Add the BOM byte sequence to indicate UTF-8 encoding to the translations
CSV download so that Excel will recognise the file as UTF-8 and preserve
special characters if the file is directly opened in Excel.

Without this, special characters such as curly quotes and Welsh
diacritics are replaced by other characters when the file is opened in
Excel.
When Excel saves a CSV file with UTF-8 encoding, it adds a BOM to the
start of the file. Delete this when reading the file so we can
successfully validate the headers with or without the BOM being present.
@stephencdaly
stephencdaly force-pushed the add-welsh-translations-upload branch from e6eb7ec to ea46ba3 Compare September 4, 2026 16:18
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

🎉 A review copy of this PR has been deployed! You can reach it at: https://pr-3087.admin.review.forms.service.gov.uk/

It may take 5 minutes or so for the application to be fully deployed and working. If it still isn't ready
after 5 minutes, there may be something wrong with the ECS task. You will need to go to the integration AWS account
to debug, or otherwise ask an infrastructure person.

For the sign in details and more information, see the review apps wiki page.

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.

1 participant