Uploaded image for project: 'ui-requests'
  1. ui-requests
  2. UIREQ-603

Internationalize back-end failure messages

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Blocked (View Workflow)
    • Priority: P2
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
    • Template:
      Standard Bug Write-Up Format
    • Sprint:
      Prokopovych - Sprint 115
    • Development Team:
      Prokopovych
    • Affected Institution:
      GBV

      Description

      Overview:

      To have back-end messages been translated we need

      1. 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, ...)
      2. the front-end to take the "code" property and create a translated message (this issue)
      3. the back-end to send the translation key in the "code" property (out of scope for this issue, see CIRC-1146)

      Steps to Reproduce:

      1. Switch to German locale
      2. Request an item that the requester currently has on loan.

      Expected Results:

      German error message.

      Actual Results:

      English error message:

      This requester currently has this item on loan.

      Translators cannot translate this because

      1. 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
      2. the front-end doesn't use the "code" property to look up a translation in the translation file (this issue) and
      3. 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):
      {
        "errors" : [ {
          "message" : "This requester currently has this item on loan.",
          "parameters" : [ {
            "key" : "itemId",
            "value" : "7212ba6a-8dcf-45a1-be9a-ffaa847c4423"
          }, {
            "key" : "userId",
            "value" : "b4cee18d-f862-4ef1-95a5-879fdd619603"
          }, {
            "key" : "loanId",
            "value" : "38c377d0-842f-4c59-952f-b56635445cd5"
          } ]
        } ]
      }

      Additional information:

      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:
      https://github.com/folio-org/raml/blob/raml1.0/schemas/error.schema
      https://github.com/folio-org/mod-circulation/blame/v20.1.5/ramls/extended-error.json

      {
        "errors" : [ {
          "code" : "mod-circulation.errors.requesterHasItemOnLoan",
          "message" : "This requester currently has this item on loan.",
          "parameters" : [ {
            "key" : "itemId",
            "value" : "7212ba6a-8dcf-45a1-be9a-ffaa847c4423"
          }, {
            "key" : "userId",
            "value" : "b4cee18d-f862-4ef1-95a5-879fdd619603"
          }, {
            "key" : "loanId",
            "value" : "38c377d0-842f-4c59-952f-b56635445cd5"
          } ]
        } ]
      }

      Task:

      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.

      Example for
      https://github.com/folio-org/mod-circulation/blob/v20.1.5/src/main/java/org/folio/circulation/domain/validation/CommonFailures.java :

      {
        "errors" : [ {
          "code" : "mod-circulation.errors.noItemFoundForBarcodeFailure",
          "message" : "No item with barcode 1234 exists.",
          "parameters" : [ {
            "key" : "itemBarcode",
            "value" : "1234"
          } ]
        } ]
      }

      Assume that the current language has this translation for the translation key:

      "mod-circulation.errors.noItemFoundForBarcodeFailure": "Es existiert kein Exemplar mit dem Barcode {itemBarcode}."

      Then front-end should show this error message:

       Es existiert kein Exemplar mit dem Barcode 1234.

      Note that "errors" is an array. Each array element results in an error message, and all of them need to be displayed. Example:

      {
        "errors" : [ {
          "code" : "mod-circulation.errors.noUserFoundForBarcodeFailure",
          "message" : "No user with barcode 98765 exists.",
          "parameters" : [ {
            "key" : "userBarcode",
            "value" : "98765"
          } ]
        }, {
          "code" : "mod-circulation.errors.noItemFoundForBarcodeFailure",
          "message" : "No item with barcode 1234 exists.",
          "parameters" : [ {
            "key" : "itemBarcode",
            "value" : "1234"
          } ]
        } ]
      }

      In scope:

      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.

      Out of scope:

      • Changing mod-circulation to send the "code" (3. in list above, see CIRC-1146)
      • Creating a file with translation keys and translation values for messages from mod-circulation (1. in list above, see UIREQ-607, , UICIRC-577, ...).

        TestRail: Results

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                Unassigned Unassigned
                Reporter:
                julianladisch Julian Ladisch
                Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                  Dates

                  Created:
                  Updated:

                    TestRail: Runs

                      TestRail: Cases