Bug 20195: Untranslatable Show/Hide title attr replacement in opac detail
authorPasi Kallinen <pasi.kallinen@joensuu.fi>
Wed, 14 Feb 2018 10:12:52 +0000 (12:12 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 19 Mar 2018 16:55:53 +0000 (13:55 -0300)
There's javascript code in opac detail view that tries to replace
the word "Show" with "Hide" (and vice versa) in a title attribute.
In addition to those words being untranslatable, a word replacement
like that would not work properly when using other languages.

Replace the single title attribute with two translatable strings,
one for the "Show" case and one "Hide", and use the whole
string instead of trying to replace a single word.

Test plan:

1) Make sure OpacBrowseResults is on
2) in OPAC, search the catalog and go to the detail view
3) Hover the mouse over the "Browse results" text in the grey box on the
   right side. The popup text should show something like
   "Show pagination list (1-5 / 5)"
4) Click on the "Browse results"
5) Hover the mouse again over the text. The popup should show
   "Hide pagination list (1-5 / 5)"
6) Update a language xx-YY, translate the new msgids
   "Show pagination list (%s-%s / %s)" and
   "Hide pagination list (%s-%s / %s)", and install the language
7) Repeat 2-5 with that language, making sure the popup
   texts show up correctly in that language

Signed-off-by: Pasi Kallinen <pasi.kallinen@joensuu.fi>

Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt

index 3372637..4801f90 100644 (file)
                     <div class="nav_results">
                         <div class="l_Results">
                             [% IF ( listResults ) %]
-                                <a href="#" id="a_listResults" title="Show pagination list ([% indexPag %]-[% indexPagEnd %] / [% totalPag %])">Browse results</a>
+                                <a href="#" id="a_listResults">Browse results</a>
                             [% ELSE %]
                                 <span>Browse results</span>
                             [% END %]
     [% END %]
 
     [% IF ( OpacBrowseResults && busc ) %]
+        var list_title_showmsg = _("Show pagination list (%s-%s / %s)").format([% indexPag %], [% indexPagEnd %], [% totalPag %]);
+        var list_title_hidemsg = _("Hide pagination list (%s-%s / %s)").format([% indexPag %], [% indexPagEnd %], [% totalPag %]);
         if (arrPagination.length > 0) {
             renderPagIndexList(pag_index_ini, $("#listResults"));
+            var reslist = $("#a_listResults");
+            reslist.attr('title', list_title_showmsg);
         }
         $("#a_listResults").click(function(e) {
             if (arrPagination.length > 0) {
                 var navigation = $(".results-pagination");
                 if (navigation.css("display") == 'none') {
                     navigation.show();
-                    var newtitle = $(this).attr('title').replace('Show', 'Hide')
-                    $(this).attr('title',newtitle);
+                    $(this).attr('title',list_title_hidemsg);
                     renderPagination(pag_index_ini, arrPagination.length - 1, $("#ul_pagination_list"), false);
                 } else {
                     navigation.hide();
-                    var newtitle = $(this).attr('title').replace('Hide', 'Show')
-                    $(this).attr('title',newtitle);
+                    $(this).attr('title',list_title_showmsg);
                 }
             }
         });