> For the complete documentation index, see [llms.txt](https://spice.docs.medtroniclabs.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://spice.docs.medtroniclabs.org/admin-guide/multi-language-translation/support-for-multiple-languages.md).

# Support for multiple languages

This page walks an implementer through adding a language. Read the [overview](https://spice.docs.medtroniclabs.org/admin-guide/multi-language-translation.md) first for what is translated and where.

In the examples below, `<language>`, `<code>` and `<translated ...>` are placeholders. Replace them with your own language name, language code and translated text.

## Before you start

You need:

* the language's display name and its short code (for example a two-letter code);
* translations of the mobile app's fixed interface text;
* translations of form content and reference-list values you want shown in that language;
* a way to build and release a new version of the mobile app, because the app must be updated to offer a new language.

## Step 1. Register the language

The platform keeps a list of languages. Each entry has:

| Property  | Meaning                                                                                                                    |
| --------- | -------------------------------------------------------------------------------------------------------------------------- |
| Name      | The name users see in the language chooser. Use the name in the language itself if you want it to read naturally to users. |
| Code      | A short language code.                                                                                                     |
| App types | Which app types the language is offered to.                                                                                |

Add the entry as part of platform setup. The admin portal has no screen for creating languages. Once the entry exists, it appears in:

* the **Language** field when you create or edit a health facility;
* the **Culture** field on user forms where that field is shown;
* the language drop-down on the standard forms in the region customisation page;
* the language chooser in the mobile app.

## Step 2. Translate reference lists

Reference lists such as symptoms and other pick-lists store a translated value beside the default value. Supply the translated value for each item you want shown in the new language. If an item has no translated value, the app falls back to the default text.

Reference data is cached by the platform. After changing it, clear the cache or restart the affected service so that the new text is served.

## Step 3. Translate form content

Forms used by the app carry a second-language value next to each piece of default text. The structure is the same for every field type.

| Default text            | Translated text       | Used for                                     |
| ----------------------- | --------------------- | -------------------------------------------- |
| `title`                 | `titleCulture`        | Field and section titles                     |
| `hint`                  | `hintCulture`         | Placeholder text                             |
| `errorMessage`          | `cultureErrorMessage` | Validation messages                          |
| `name` inside an option | `cultureValue`        | Option labels in drop-downs and radio groups |

Example of a field with a translated title, hint and error message:

```json
{
  "id": "firstName",
  "viewType": "EditText",
  "title": "First Name",
  "titleCulture": "<translated First Name>",
  "hint": "Enter First Name",
  "hintCulture": "<translated Enter First Name>",
  "errorMessage": "First name is required",
  "cultureErrorMessage": "<translated First name is required>"
}
```

Example of an option list:

```json
{
  "id": "category",
  "viewType": "Spinner",
  "title": "Category",
  "titleCulture": "<translated Category>",
  "optionsList": [
    { "id": "Tablet", "name": "Tablet", "cultureValue": "<translated Tablet>" }
  ]
}
```

Where the form is stored decides how you add the translation:

* **Standard Screening, Enrollment and Assessment forms.** These are stored once per language. Make sure a version exists for the new language, then open it in the portal with the language drop-down and adjust it. See [Workflow & Form Configuration](https://spice.docs.medtroniclabs.org/admin-guide/clinical-workflow-customization.md). The portal shows field names, display names and option lists on these forms as read-only, so translated text for them is supplied when the language's form version is set up.
* **Forms built into the app.** Their translated text is part of the app and changes only with a new app release.
* **Customised workflow forms.** Built in the portal's form builder.

## Step 4. Add the language to the mobile app

This step needs an app developer and a new app release.

1. Add a locale-specific set of string resources for the language, containing the translations of the app's fixed interface text. Any text missing from the new set falls back to the default language.
2. Update the app's language handling so that it recognises the new language and its code. The app currently recognises a fixed set of languages when it chooses the interface language, and treats any other language as the default.
3. Check how the app decides whether to show second-language form content. Today that decision is tied to specific configured languages, so a new language needs to be added to it if you want translated form content to appear.
4. Build and release the app.

## Step 5. Assign the language

* Set the **Language** on each health facility that should use it.
* Set the **Culture** on users where your deployment shows that field.

## Step 6. Users switch language in the app

1. In the app, open the language option and select the language.
2. Confirm the prompt. The app saves the choice on the server and signs the user out.
3. Sign in again. The app downloads fresh configuration and shows the chosen language.

## Admin portal and reporting application

The admin portal and the reporting web application are available in the default language only. There is no language switch to configure for them.

## Troubleshooting

| Symptom                                           | Likely cause                                                                                                                                                    |
| ------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| The language does not appear in the app's chooser | The language is not in the platform's language list, or it is not marked for the app type in use. The user may also need to sign in again to download the list. |
| Interface text stays in the default language      | The installed app release does not include string resources or language handling for that language.                                                             |
| Some form text is translated and some is not      | The form has no translated value for those items. The app shows the default text for them.                                                                      |
| Translated reference values do not appear         | The reference data cache has not been refreshed, or the user has not downloaded fresh configuration since the change.                                           |
