Add welsh translations upload - #3087
Draft
stephencdaly wants to merge 9 commits into
Draft
Conversation
stephencdaly
force-pushed
the
add-welsh-translations-upload
branch
from
September 4, 2026 11:43
83cf72e to
e6eb7ec
Compare
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
force-pushed
the
add-welsh-translations-upload
branch
from
September 4, 2026 16:18
e6eb7ec to
ea46ba3
Compare
|
🎉 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 For the sign in details and more information, see the review apps wiki page. |
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.
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:
Things to consider when reviewing