Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sierra: Add translation prefix support for ILS messages. #3140

Merged
merged 2 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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