|
| 1 | +# Adding Welsh to a Form |
| 2 | + |
| 3 | +This document describes how adding a Welsh translation affect a form and it's form documents. |
| 4 | + |
| 5 | +## The Welsh tasklist status |
| 6 | + |
| 7 | +The Welsh task is optional. If the form creator does nothing, it will not block the form from being made live. |
| 8 | + |
| 9 | +If the task is started, by entering any values into the translation screen and submitting it as unfinished, the status will be set to in progress. |
| 10 | + |
| 11 | +The form cannot be made live while the Welsh task is in progress. |
| 12 | + |
| 13 | +If the task is completed, by entering a full translation of the form and submitting it as finished, the status will be set to complete and the form can be made live. |
| 14 | + |
| 15 | +Any changes to the form or translation which would mean that the Welsh is no longer complete, such as adding a declaration, new question, exit page or support method will |
| 16 | +set the status to in progress. |
| 17 | + |
| 18 | +```mermaid |
| 19 | +stateDiagram-v2 |
| 20 | + Optional --> In_Progress:Enter Welsh, save unfinished |
| 21 | + Optional --> Complete:Enter Welsh, save finished |
| 22 | + Complete --> Optional:Delete Welsh |
| 23 | + In_Progress --> Optional:Delete Welsh |
| 24 | + In_Progress --> Complete:Enter Welsh, save unfinished |
| 25 | + Complete --> In_Progress:Invalidate Welsh |
| 26 | +``` |
| 27 | + |
| 28 | +## New fields on Form |
| 29 | + |
| 30 | +## available_languages |
| 31 | + |
| 32 | +`available_languages`, is an array of language codes. It's `[:en]` by default, which signals that the form is only available in English. |
| 33 | +Forms with a Welsh translation have `[:en, :cy]` in the array. |
| 34 | + |
| 35 | +As soon as the Welsh translation page is submitted with at least one value for a field, the `available_languages` array will be updated. |
| 36 | + |
| 37 | +The `available_languages` array is used when generating form documents, which are used by the runner. Form documents are created for each language in the array. |
| 38 | +It's updated when the Welsh translation is submitted so the user can immediately preview the Welsh translation, even if they haven't completed it. |
| 39 | + |
| 40 | +The `available_languages` array is saved in form documents. It's used by the runner to discover that the form is available in Welsh, if it's showing the English version. |
| 41 | + |
| 42 | +### welsh_completed |
| 43 | +`welsh_completed` is a boolean, which is records if the form creator has marked the Welsh as complete. It's not included in form_documents. |
| 44 | + |
| 45 | +## Places where the values change |
| 46 | + |
| 47 | +If the English form changes, we need to update the Welsh translation to match. This can happen if the form creator deletes a field, such as a declaration. |
| 48 | +To keep the Welsh translation in sync, Form has a new method |
| 49 | +`normalise_welsh!`. It's called when the form documents for draft or live are |
| 50 | +made. It ensures that the Welsh translation doesn't have any values which the |
| 51 | +English form doesn't have. |
| 52 | + |
| 53 | +The method on Form in turn calls `normalise_welsh!` on each page and condition, which syncs these values. |
0 commit comments