From f7a9fc7849eb91cec91c5ef575ff1fb90dc47f17 Mon Sep 17 00:00:00 2001 From: Ere Maijala Date: Wed, 4 Oct 2023 14:29:04 +0300 Subject: [PATCH] Sierra: Add translation prefix support for ILS messages. (#3140) --- config/vufind/SierraRest.ini | 6 ++++++ module/VuFind/src/VuFind/ILS/Driver/SierraRest.php | 12 ++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/config/vufind/SierraRest.ini b/config/vufind/SierraRest.ini index 2306e94295c..2c780f44e33 100644 --- a/config/vufind/SierraRest.ini +++ b/config/vufind/SierraRest.ini @@ -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 diff --git a/module/VuFind/src/VuFind/ILS/Driver/SierraRest.php b/module/VuFind/src/VuFind/ILS/Driver/SierraRest.php index e8fcfe262fb..aa3474c9e01 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/SierraRest.php +++ b/module/VuFind/src/VuFind/ILS/Driver/SierraRest.php @@ -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 = [ @@ -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, ]; } @@ -2855,7 +2855,7 @@ function ($matches) { }, $msg ); - return $msg; + return ($this->config['Catalog']['translationPrefix'] ?? '') . $msg; } /**