To have back-end messages been translated we need
- entries in a translation file, for example https://github.com/folio-org/ui-requests/blob/master/translations/ui-requests/en.json , that the translators can translate (out of scope of this issue, see UIREQ-607, UICIRC-577, ...)
- the front-end to take the "code" property and create a translated message (this issue)
- the back-end to send the translation key in the "code" property (out of scope for this issue, see CIRC-1146)
Steps to Reproduce:
- Switch to German locale
- Request an item that the requester currently has on loan.
German error message.
English error message:
Translators cannot translate this because
- there is no entry in the translation file https://github.com/folio-org/ui-requests/blob/master/translations/ui-requests/en.json (out of scope of this issue, see UIREQ-607, UICIRC-577, ...) and
- the front-end doesn't use the "code" property to look up a translation in the translation file (this issue) and
- because of this the back-end doesn't know which translation code to send as "code" property (out of scope of this issue, see CIRC-1146):
Currently the back-end doesn't send a "code" property (out of scope of this issue, see CIRC-1146) but declares it in the error.schema/extended-error.json:
For this issue assume that the back-end fills the "code" property with a valid translation key that can be used to lookup the translated error message. (If there is no "code" property simply display the "message" property without translation as before.)
The "parameters" are the placeholders for the icu message syntax.
Assume that the current language has this translation for the translation key:
Then front-end should show this error message:
Note that "errors" is an array. Each array element results in an error message, and all of them need to be displayed. Example:
Use the "code" property to look up a translation and replace placeholders (2. in list above). If there is no "code" property display the "message" property without translation.