Skip to content

Commit

Permalink
Sierra: Add translation prefix support for ILS messages. (#3140)
Browse files Browse the repository at this point in the history
  • Loading branch information
EreMaijala authored Oct 4, 2023
1 parent f4cd159 commit f7a9fc7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions config/vufind/SierraRest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ use_prefixed_ids = false
; Default is 2. Set to 0 to disable retries.
;http_retries = 2

; Translation prefix to use for messages coming from Sierra. By default a prefix is
; not used, but a prefix may be used to distinguish the codes from any other
; translations (or other libraries). You can use a simple prefix in the default
; domain (e.g. "sierra_") or a custom text domain (e.g. "ILSMessages::").
;translationPrefix = "ILSMessages::"

[Authentication]
; When using patron-specific data access, different values may be used as the
; username and password when the user logs in via CAS, depending on how Sierra is
Expand Down
12 changes: 6 additions & 6 deletions module/VuFind/src/VuFind/ILS/Driver/SierraRest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ public function placeHold($holdDetails)

// Make sure pickup location is valid
if (!$this->pickUpLocationIsValid($pickUpLocation, $patron, $holdDetails)) {
return $this->holdError('hold_invalid_pickup');
return $this->holdError('hold_invalid_pickup', false);
}

$request = [
Expand Down Expand Up @@ -2818,16 +2818,16 @@ protected function pickUpLocationIsValid($pickUpLocation, $patron, $holdDetails)
*
* Returns a Hold Error Message
*
* @param string $msg An error message string
* @param string $msg An error message string
* @param bool $ilsMsg Whether the error is an ILS error message (needs formatting and any translations prefix)
*
* @return array An array with a success (boolean) and sysMessage key
*/
protected function holdError($msg)
protected function holdError($msg, bool $ilsMsg = true)
{
$msg = $this->formatErrorMessage($msg);
return [
'success' => false,
'sysMessage' => $msg,
'sysMessage' => $ilsMsg ? $this->formatErrorMessage($msg) : $msg,
];
}

Expand Down Expand Up @@ -2855,7 +2855,7 @@ function ($matches) {
},
$msg
);
return $msg;
return ($this->config['Catalog']['translationPrefix'] ?? '') . $msg;
}

/**
Expand Down

0 comments on commit f7a9fc7

Please sign in to comment.