diff --git a/code/web/interface/plugins/function.translate.php b/code/web/interface/plugins/function.translate.php
index adae62c740..317118c890 100644
--- a/code/web/interface/plugins/function.translate.php
+++ b/code/web/interface/plugins/function.translate.php
@@ -1,5 +1,5 @@
$param) {
if (is_numeric($index)) {
$replacementValues[$index] = $param;
}
}
- return $translator->translate($params['text'], $defaultText, $replacementValues, $inAttribute, $isPublicFacing, $isAdminFacing, $isMetadata, $isAdminEnteredData, $translateParameters);
+ return $translator->translate($params['text'], $defaultText, $replacementValues, $inAttribute, $isPublicFacing, $isAdminFacing, $isMetadata, $isAdminEnteredData, $translateParameters, $escape);
} else {
return $translator->translate($params, null, [], false);
}
diff --git a/code/web/interface/themes/responsive/Admin/propertiesList.tpl b/code/web/interface/themes/responsive/Admin/propertiesList.tpl
index 9ea089261b..21cd2b2618 100644
--- a/code/web/interface/themes/responsive/Admin/propertiesList.tpl
+++ b/code/web/interface/themes/responsive/Admin/propertiesList.tpl
@@ -209,8 +209,8 @@
{/if}
{if !empty($canExportToCSV) && !empty($dataList)}
- {translate text=$thisFacet.display|escape isPublicFacing=true}
+ {translate text=$thisFacet.display isPublicFacing=true}
({translate text=Remove isPublicFacing=true})
@@ -29,7 +29,7 @@
- {translate text=$thisFacet.display|escape isPublicFacing=true}{if $facetCountsToShow == 1 || ($facetCountsToShow == 2 && empty($thisFacet.countIsApproximate))}
({if !empty($thisFacet.countIsApproximate)}{/if}{$thisFacet.count|number_format:0:".":","}){/if}
+ {translate text=$thisFacet.display isPublicFacing=true}{if $facetCountsToShow == 1 || ($facetCountsToShow == 2 && empty($thisFacet.countIsApproximate))}
({if !empty($thisFacet.countIsApproximate)}{/if}{$thisFacet.count|number_format:0:".":","}){/if}
@@ -45,9 +45,9 @@
{foreach from=$cluster.list item=thisFacet name="narrowLoop"}
{if !empty($thisFacet.isApplied)}
-
+
{else}
-
+
{/if}
{/foreach}
diff --git a/code/web/interface/themes/responsive/Search/Recommend/dropDownFacet.tpl b/code/web/interface/themes/responsive/Search/Recommend/dropDownFacet.tpl
index 41ad97c130..748dd8557e 100644
--- a/code/web/interface/themes/responsive/Search/Recommend/dropDownFacet.tpl
+++ b/code/web/interface/themes/responsive/Search/Recommend/dropDownFacet.tpl
@@ -5,6 +5,6 @@
{/if}
{if !empty($thisFacet.isApplied)}
-
+
{else}
-
{if $thisFacet.url !=null}
{/if}{$thisFacet.display|escape}{if $thisFacet.url !=null}{/if}{if $facetCountsToShow == 1 || ($facetCountsToShow == 2 && empty($thisFacet.countIsApproximate))}{if $thisFacet.count != ''} ({if !empty($thisFacet.countIsApproximate)}{/if}{$thisFacet.count|number_format}){/if}{/if}
+
{if $thisFacet.url !=null}
{/if}{$thisFacet.display}{if $thisFacet.url !=null}{/if}{if $facetCountsToShow == 1 || ($facetCountsToShow == 2 && empty($thisFacet.countIsApproximate))}{if $thisFacet.count != ''} ({if !empty($thisFacet.countIsApproximate)}{/if}{$thisFacet.count|number_format}){/if}{/if}
{/if}
{/foreach}
{if $smarty.foreach.narrowLoop.total > $cluster.valuesToShow}
@@ -30,7 +30,7 @@
@@ -45,9 +45,9 @@
{/if}
{if !empty($thisFacet.isApplied)}
-
+
{else}
-
{if $thisFacet.url !=null}
{/if}{$thisFacet.display|escape}{if $thisFacet.url !=null}{/if}{if $facetCountsToShow == 1 || ($facetCountsToShow == 2 && empty($thisFacet.countIsApproximate))}{if $thisFacet.count != ''} ({if !empty($thisFacet.countIsApproximate)}{/if}{$thisFacet.count|number_format}){/if}{/if}
+
{if $thisFacet.url !=null}
{/if}{$thisFacet.display}{if $thisFacet.url !=null}{/if}{if $facetCountsToShow == 1 || ($facetCountsToShow == 2 && empty($thisFacet.countIsApproximate))}{if $thisFacet.count != ''} ({if !empty($thisFacet.countIsApproximate)}{/if}{$thisFacet.count|number_format}){/if}{/if}
{/if}
{/foreach}
{if $smarty.foreach.narrowLoop.total > $cluster.valuesToShow}
diff --git a/code/web/release_notes/24.06.00.MD b/code/web/release_notes/24.06.00.MD
index c71b049d72..a7b5135a1c 100644
--- a/code/web/release_notes/24.06.00.MD
+++ b/code/web/release_notes/24.06.00.MD
@@ -51,6 +51,10 @@
+### Other Updates
+- Update escaping of facet values so that translatable facet values can be translated in translation mode. (Tickets 130428, 130798) (*MDN*)
+- Fix translation mode for Export to CSV buttons in the Admin interface.
+
//kirstien
### Accessibility Updates
- Libby lending period options are now select elements to make them keyboard accessible and easily indicate selected values. (*KK*)
diff --git a/code/web/sys/SearchObject/BaseSearcher.php b/code/web/sys/SearchObject/BaseSearcher.php
index 89f6a598f2..d7dd48a0d6 100644
--- a/code/web/sys/SearchObject/BaseSearcher.php
+++ b/code/web/sys/SearchObject/BaseSearcher.php
@@ -374,6 +374,7 @@ public function getFilterList() {
$display = $translate ? translate([
'text' => $value,
'isPublicFacing' => true,
+ 'escape' => true,
]) : $value;
}
@@ -1327,6 +1328,7 @@ public function getLimitList() {
'display' => $limit,
'value' => $limit,
'isApplied' => ($limit == $this->limit),
+ 'escape' => true,
];
}
}
diff --git a/code/web/sys/SearchObject/GroupedWorkSearcher2.php b/code/web/sys/SearchObject/GroupedWorkSearcher2.php
index fc3bad9009..6cb309e921 100644
--- a/code/web/sys/SearchObject/GroupedWorkSearcher2.php
+++ b/code/web/sys/SearchObject/GroupedWorkSearcher2.php
@@ -796,8 +796,9 @@ public function getFacetList($filter = null) {
$currentSettings['display'] = $translate ? translate([
'text' => $facetValue,
'isPublicFacing' => true,
- 'isMetadata' => true
- ]) : $facetValue;
+ 'isMetadata' => true,
+ 'escape' => true,
+ ]) : htmlentities($facetValue);
$currentSettings['count'] = $facet[1];
$currentSettings['isApplied'] = false;
$currentSettings['url'] = $this->renderLinkWithFilter($field, $facetValue);
@@ -879,8 +880,16 @@ public function getFacetList($filter = null) {
if (!$foundInstitution && $doInstitutionProcessing) {
$list[$field]['list']['1' . $currentLibrary->facetLabel] = [
- 'value' => $currentLibrary->facetLabel,
- 'display' => $currentLibrary->facetLabel,
+ 'value' => $translate ? translate([
+ 'text' => $currentLibrary->facetLabel,
+ 'isPublicFacing' => true,
+ 'escape' => true
+ ]) : htmlentities($currentLibrary->facetLabel),
+ 'display' => $translate ? translate([
+ 'text' => $currentLibrary->facetLabel,
+ 'isPublicFacing' => true,
+ 'escape' => true
+ ]) : htmlentities($currentLibrary->facetLabel),
'count' => 0,
'isApplied' => false,
'url' => null,
@@ -888,8 +897,16 @@ public function getFacetList($filter = null) {
}
if (!$foundBranch && $doBranchProcessing && !empty($activeLocationFacet)) {
$list[$field]['list']['1' . $activeLocationFacet] = [
- 'value' => $activeLocationFacet,
- 'display' => $activeLocationFacet,
+ 'value' => $translate ? translate([
+ 'text' => $activeLocationFacet,
+ 'isPublicFacing' => true,
+ 'escape' => true
+ ]) : htmlentities($activeLocationFacet),
+ 'display' => $translate ? translate([
+ 'text' => $activeLocationFacet,
+ 'isPublicFacing' => true,
+ 'escape' => true
+ ]) : htmlentities($activeLocationFacet),
'count' => 0,
'isApplied' => false,
'url' => null,
diff --git a/code/web/sys/Translation/Translator.php b/code/web/sys/Translation/Translator.php
index c333cfc132..68e7c69e31 100644
--- a/code/web/sys/Translation/Translator.php
+++ b/code/web/sys/Translation/Translator.php
@@ -64,15 +64,16 @@ function parseLanguageFile($file) {
* @param string $phrase - The phrase to translate
* @param string $defaultText - The default text for a phrase that is just a key for a longer phrase
* @param string[] $replacementValues - Values to replace within the string
- * @param bool $inAttribute - Whether or not we are in an attribute. If we are, we can't show the span
- * @param bool $isPublicFacing - Whether or not the public will see this
- * @param bool $isAdminFacing - Whether or not this is in the admin interface
- * @param bool $isMetadata - Whether or not this is a translation of metadata in a MARC record, OverDrive, Axis360, etc
- * @param bool $isAdminEnteredData - Whether or not this is data an administrator entered (System message, etc)
- * @param bool $translateParameters - Whether or not parameters should be translated
+ * @param bool $inAttribute - Whether we are in an attribute. If we are, we can't show the span
+ * @param bool $isPublicFacing - Whether the public will see this
+ * @param bool $isAdminFacing - Whether this is in the admin interface
+ * @param bool $isMetadata - Whether this is a translation of metadata in a MARC record, OverDrive, Axis360, etc
+ * @param bool $isAdminEnteredData - Whether this is data an administrator entered (System message, etc)
+ * @param bool $translateParameters - Whether parameters should be translated
+ * @param bool $escape - Whether the translation should be escaped before rendering
* @return string - The translated phrase
*/
- function translate($phrase, $defaultText = '', $replacementValues = [], $inAttribute = false, $isPublicFacing = false, $isAdminFacing = false, $isMetadata = false, $isAdminEnteredData = false, $translateParameters = false) {
+ function translate($phrase, $defaultText = '', $replacementValues = [], $inAttribute = false, $isPublicFacing = false, $isAdminFacing = false, $isMetadata = false, $isAdminEnteredData = false, $translateParameters = false, $escape = false) : string {
if ($phrase == '' || is_numeric($phrase)) {
return $phrase;
}
@@ -211,6 +212,9 @@ function translate($phrase, $defaultText = '', $replacementValues = [], $inAttri
$translation->update();
}
+ if ($escape) {
+ $translation->translated = htmlentities( $translation->translation);
+ }
if ($translationMode) {
if ($translation->translated) {
$translationStatus = 'translated';
@@ -228,6 +232,9 @@ function translate($phrase, $defaultText = '', $replacementValues = [], $inAttri
$returnString = $fullTranslation;
} else {
$returnString = $existingTranslation;
+ if ($escape) {
+ $returnString = htmlentities( $returnString);
+ }
}
} else {
//Translation not setup (happens from book covers)
@@ -239,7 +246,6 @@ function translate($phrase, $defaultText = '', $replacementValues = [], $inAttri
}
} catch (PDOException $e) {
//tables likely don't exist, ignore
- $returnString = $phrase;
if (!empty($defaultText)) {
$returnString = $defaultText;
} else {