From 585045a04253a29146f1e047e79d1689eac03fcd Mon Sep 17 00:00:00 2001 From: Robert Lange <robert.lange@uni-leipzig.de> Date: Tue, 10 Nov 2020 14:39:15 +0100 Subject: [PATCH] refs #18509 [finc] add language tags * in menu of side facets: ** by using SideFacets helper ** setting terms to decorate in facets.ini * in footer: ** remove empty call to layout()->poweredBy ** translate poweredBy ** remove language tag of poweredBy, because it's translated ** use external link view helper for footer images ** set aria-hidden to true for images * adjust alt text for footer images (like UBL) in language files --- local/config/vufind/facets.ini | 12 +++++++ local/languages/de.ini | 5 +-- local/languages/en.ini | 5 +-- .../src/finc/View/Helper/Root/SideFacet.php | 20 +++++++++++ .../Recommend/SideFacets/filter-list.phtml | 33 +++++++++++++++++++ .../Recommend/SideFacets/single-facet.phtml | 3 ++ themes/finc/templates/footer.phtml | 13 +++----- 7 files changed, 79 insertions(+), 12 deletions(-) create mode 100644 themes/finc/templates/Recommend/SideFacets/filter-list.phtml diff --git a/local/config/vufind/facets.ini b/local/config/vufind/facets.ini index 5b406598175..fdf7ccf912b 100644 --- a/local/config/vufind/facets.ini +++ b/local/config/vufind/facets.ini @@ -239,3 +239,15 @@ hide_facets = "genre_facet,era_facet,geographic_facet" ; Special facets sorted alphabetically. [SortedByIndex] ;index[] = format + +; Special terms (key), which can't / shouldn't be translated but marked as other language (value) for BARF reasons +[LanguageTags] +De Gruyter Journals / Social Sciences and Humanities = "en" +Free = "en" +JSTOR Music Archive = "en" +Local = "en" +Microform = "en" +Open Access = "en" +Online = "en" +Proceeding = "en" +Répertoire International des Sources Musicales = "fr" diff --git a/local/languages/de.ini b/local/languages/de.ini index b257ab271cb..927519966e5 100644 --- a/local/languages/de.ini +++ b/local/languages/de.ini @@ -1803,11 +1803,12 @@ footer_ezb = "Elektronische Zeitschriftenbibliothek (EZB)" footer_kvk = "Karlsruher Virtueller Katalog (KVK)" footer_dbis = "Datenbankinformationssystem (DBIS)" footer_nwb = "nwb-Datenbank" +Footer-Powered-By-Text = "Betrieben mit" ; Powered by alt and title tags -vufind-logo_alt = "VuFind" +vufind-logo_alt = "VuFind-Software" vufind-logo_title = "Weitere Informationen in englischer Sprache finden Sie auf VuFind.org" -finc-logo_alt = "finc" +finc-logo_alt = "finc-Software" finc-logo_title = "Weitere Informationen zu 'finc' finden Sie in unserem finc-Blog" ; source providers diff --git a/local/languages/en.ini b/local/languages/en.ini index a4cb46bf4b9..e91a899716e 100644 --- a/local/languages/en.ini +++ b/local/languages/en.ini @@ -1921,11 +1921,12 @@ footer_ezb = "Electronic Journals Library (EZB)" footer_kvk = "Karlsruhe Virtual Catalog (KVK)" footer_dbis = "Database Information System (DBIS)" footer_nwb = "Database nwb" +Footer-Powered-By-Text = "Powered by" ; Powered by alt and title tags -vufind-logo_alt = "VuFind" +vufind-logo_alt = "VuFind software" vufind-logo_title = "For further informationen please visit VuFind.org" -finc-logo_alt = "finc" +finc-logo_alt = "finc software" finc-logo_title = "For further informationen in German on 'finc' please visit our finc-Blog" ; Tab to Close-text for closing FNDTN ToolTips diff --git a/module/finc/src/finc/View/Helper/Root/SideFacet.php b/module/finc/src/finc/View/Helper/Root/SideFacet.php index 240b5abd29b..f1c12ba4e8a 100644 --- a/module/finc/src/finc/View/Helper/Root/SideFacet.php +++ b/module/finc/src/finc/View/Helper/Root/SideFacet.php @@ -89,4 +89,24 @@ class SideFacet extends AbstractHelper } return $sideFacets; } + + /** + * Get term with corresponding language tag within html element + * + * @param string $term translation to decorate with language tag + * @param string $element wrapping html element + * @param string $language current language + * + * @return string + */ + public function getLanguageTag(string $term, string $element, string $language) + { + $retval = $term; + + if (isset($this->config->LanguageTags[$term]) && $this->config->LanguageTags[$term] !== $language) { + $retval = "<$element " . 'lang="' . $this->config->LanguageTags[$term] . '">' . "$term</$element>"; + } + + return $retval; + } } diff --git a/themes/finc/templates/Recommend/SideFacets/filter-list.phtml b/themes/finc/templates/Recommend/SideFacets/filter-list.phtml new file mode 100644 index 00000000000..480226de443 --- /dev/null +++ b/themes/finc/templates/Recommend/SideFacets/filter-list.phtml @@ -0,0 +1,33 @@ +<!-- finc - Recommend - SideFacets - filter-list.phtml --> +<?php /* #18509 copied from bootstrap for adding language tags to displayText */ ?> +<div class="facet-group active-filters"> + <div class="title"><?=$this->transEsc('Remove Filters')?></div> + <?php foreach ($filterList as $field => $filters): ?> + <?php foreach ($filters as $i => $filter): ?> + <?php + $index = isset($filter['field']) ? array_search($filter['field'], $collapsedFacets) : false; + if ($index !== false) { + unset($collapsedFacets[$index]); // Open if we have a match + } + if (isset($filter['specialType']) && $filter['specialType'] == 'keyword') { + $removeLink = $this->currentPath() . $results->getUrlQuery()->replaceTerm($filter['value'], ''); + } else { + $removeLink = $this->currentPath() . $results->getUrlQuery()->removeFacet($filter['field'], $filter['value'], $filter['operator']); + } + if ($filter['displayText'] == '[* TO *]') { + $filter['displayText'] = $this->translate('filter_wildcard'); + } + ?> + <a class="facet" href="<?=$removeLink ?>" title="<?=$this->transEsc('clear_tag_filter') ?>"> + <span class="sr-only"><?=$this->transEsc('clear_tag_filter') ?></span> + <span class="text"> + <?php if ($filter['operator'] == 'NOT'): ?><?=$this->transEsc('NOT') ?><?php endif; ?> + <?php if ($filter['operator'] == 'OR' && $i > 0): ?><?=$this->transEsc('OR') ?><?php endif; ?> + <?=$this->transEsc($field) ?>: <?=$this->sideFacet()->getLanguageTag($this->escapeHtml($filter['displayText']), 'span', $this->layout()->userLang) ?> + </span> + <span class="status"><i class="fa fa-times" aria-hidden="true"></i></span> + </a> + <?php endforeach; ?> + <?php endforeach; ?> +</div> +<!-- finc - Recommend - SideFacets - filter-list.phtml - END --> diff --git a/themes/finc/templates/Recommend/SideFacets/single-facet.phtml b/themes/finc/templates/Recommend/SideFacets/single-facet.phtml index 58b71027afa..bedb8055591 100644 --- a/themes/finc/templates/Recommend/SideFacets/single-facet.phtml +++ b/themes/finc/templates/Recommend/SideFacets/single-facet.phtml @@ -21,6 +21,9 @@ $displayText = $this->escapeHtml($this->facet['value']); } + // #18509 decorate special untranslated terms with language tags + $displayText = $this->sideFacet()->getLanguageTag($displayText, 'span', $this->layout()->userLang); + if ($this->facet['operator'] == 'OR') { $displayText = '<i class="fa ' . ($this->facet['isApplied'] ? 'fa-check-square-o' : 'fa-square-o') . '" aria-hidden="true"></i> ' diff --git a/themes/finc/templates/footer.phtml b/themes/finc/templates/footer.phtml index 926350450de..b39d33f6ade 100644 --- a/themes/finc/templates/footer.phtml +++ b/themes/finc/templates/footer.phtml @@ -34,14 +34,11 @@ <hr> <div class="footer-container powered-by"> <div class="footer-column"> - <?=$this->layout()->poweredBy?> - <span lang="en">Powered by</span> - <a href="https://vufind.org/" title="<?=$this->transEsc('vufind-logo_title')?>" target="_blank"> - <img src="<?=$this->imageLink('vufind_logo.png')?>" alt="<?=$this->transEsc('vufind-logo_alt')?>"/> - </a> - <a href="http://blog.finc.info" title="<?=$this->transEsc('finc-logo_title')?>" target="_blank"> - <img src="<?=$this->imageLink('finc_logo.png')?>" alt="<?=$this->transEsc('finc-logo_alt')?>"/> - </a> + <span> + <?= $this->transEsc("Footer-Powered-By-Text") ?> + </span> + <?= $this->externalLink("https://vufind.org", '<img src="' . $this->imageLink('vufind_logo.png') . '" alt="' . $this->translate('vufind-logo_alt') . '" aria-hidden="true"/>', ['title' => $this->translate('vufind-logo_title')]) ?> + <?= $this->externalLink("http://blog.finc.info", '<img src="' . $this->imageLink('finc_logo.png') . '" alt="' . $this->translate('finc-logo_alt') . '" aria-hidden="true"/>', ['title' => $this->translate('finc-logo_title'), 'aria-hidden' => 'true']) ?> </div> </div> </footer> -- GitLab