added app translations for better maintainability
This commit is contained in:
@ -287,28 +287,32 @@ Success:
|
||||
}
|
||||
```
|
||||
|
||||
The translation map is grouped by language code. Each language contains a flat key-value map.
|
||||
The translation map is grouped by language code. Each language contains a flat key-value map of **app UI strings only** (screens, toasts, auth labels, etc.). Questionnaire question/option text is **not** included here.
|
||||
|
||||
Translation keys can come from:
|
||||
|
||||
- question default text, exposed as `question`
|
||||
- answer option default text, exposed as `options[].key`
|
||||
- general string keys from `string_translation`, such as hints, labels, symptoms, and text keys
|
||||
|
||||
Android lookup process:
|
||||
Android lookup for app UI:
|
||||
|
||||
1. Load `translations[activeLanguage]`.
|
||||
2. For each questionnaire string, look up the string value as a key.
|
||||
3. If a translation is missing, fall back to the raw key from the questionnaire JSON.
|
||||
2. Look up the string key (e.g. `save`, `client_code`).
|
||||
3. If missing, fall back to embedded defaults in the app.
|
||||
|
||||
## Questionnaire detail translations
|
||||
|
||||
`GET /api/app_questionnaires?id=<questionnaireID>` includes a sibling `translations` object with the same shape (language code → key → text), scoped to that questionnaire only:
|
||||
|
||||
- question default text (`question` field values)
|
||||
- answer option default text (`options[].key`)
|
||||
- questionnaire config string keys (`textKey`, hints, symptoms, etc.), excluding global app UI catalog keys
|
||||
|
||||
Android should apply this map while a questionnaire is open (overlay on top of app UI translations), then clear it when leaving the questionnaire.
|
||||
|
||||
## Recommended Android Sync Flow
|
||||
|
||||
1. Login with `/api/auth/login` and store the returned token securely.
|
||||
2. Fetch the assigned client list with `GET /api/app_questionnaires?clients=1` (coach role only).
|
||||
3. Fetch translations with `GET /api/app_questionnaires?translations=1`.
|
||||
3. Fetch app UI translations with `GET /api/app_questionnaires?translations=1`.
|
||||
4. Fetch the active questionnaire list with `GET /api/app_questionnaires`.
|
||||
5. For each list item, fetch details with `GET /api/app_questionnaires?id=<id>`.
|
||||
6. Cache the client list, translations, the questionnaire list, and questionnaire details locally for offline use.
|
||||
5. For each list item, fetch details with `GET /api/app_questionnaires?id=<id>` (includes per-questionnaire `translations`).
|
||||
6. Cache the client list, app translations, the questionnaire list, and questionnaire details (with embedded translations) locally for offline use.
|
||||
7. When a questionnaire is completed, upload answers with `POST /api/app_questionnaires`.
|
||||
|
||||
There is currently no version or `updatedAt` field in the app fetch response, so the safest refresh strategy is to re-fetch translations, list, and details at login or app start when network is available.
|
||||
|
||||
Reference in New Issue
Block a user