From 587b0ee46db6927984173ccf777f317ef35e09b7 Mon Sep 17 00:00:00 2001
From: Owen Leonard <oleonard@myacpl.org>
Date: Wed, 6 Jan 2021 16:41:48 +0000
Subject: [PATCH] Bug 27325: Fix singular/plural forms on the OPAC dashboard

This patch adds handling of plurals to the display of counts on the
logged-in user's dashboard: checkouts, overdues, etc.

To test, apply the patch and log in to the OPAC.

 - Go to the OPAC main page and check the user dashboard area.
 - Confirm that the correct numbers and plural forms are shown for
   checkouts, overdues, holds pending, holds waiting, and messages.
 - Test each of those categories with counts of 0, 1, and more than one
   to confirm that the plural forms are correct.
 - Test with various counts of each type of message: OPAC notes as
   defined when editing a patron record and notes added via the checkout
   page.
---
 .../opac-tmpl/bootstrap/en/modules/opac-main.tt    | 50 +++++++++++++++++++---
 1 file changed, 43 insertions(+), 7 deletions(-)

diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt
index 37c50aacdc..9f5f0a30fc 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt
@@ -5,6 +5,7 @@
 [% USE Categories %]
 [% USE Price %]
 [% USE KohaNews %]
+[% PROCESS 'i18n.inc' %]
 [% SET OpacNavRight = KohaNews.get( location => "OpacNavRight", lang => lang, library => branchcode ) %]
 [% SET OpacMainUserBlock = KohaNews.get( location => "OpacMainUserBlock", lang => lang, library => branchcode ) %]
 [% SET OpacLoginInstructions = KohaNews.get( location => "OpacLoginInstructions", lang => lang, library => branchcode ) %]
@@ -218,25 +219,60 @@
                                 <h3>Welcome, <a href="/cgi-bin/koha/opac-user.pl"><span class="loggedinusername">[% INCLUDE 'patron-title.inc' patron = logged_in_user %]</span></a></h3>
                                 <ul id="user_summary_shortcuts">
                                     [% IF checkouts && checkouts > 0 %]
-                                        <li><a href="/cgi-bin/koha/opac-user.pl#opac-user-checkouts"><span class="user_checkouts_count count_label">[% checkouts | html %]</span> checkout(s)</a></li>
+                                        <li>
+                                            <a href="/cgi-bin/koha/opac-user.pl#opac-user-checkouts">
+                                                <span class="user_checkouts_count count_label">[% checkouts | html %]</span>
+                                                [% tn('checkout', 'checkouts', checkouts ) %]
+                                            </a>
+                                        </li>
                                     [% END %]
                                     [% IF overdues && overdues > 0 %]
-                                        <li><a href="/cgi-bin/koha/opac-user.pl#opac-user-overdues"><span class="user_overdues_count count_label">[% overdues | html %]</span> overdue(s)</a></li>
+                                        <li>
+                                            <a href="/cgi-bin/koha/opac-user.pl#opac-user-overdues">
+                                                <span class="user_overdues_count count_label">[% overdues | html %]</span>
+                                                [% tn('overdue', 'overdues', overdues ) %]
+                                            </a>
+                                        </li>
                                     [% END %]
                                     [% IF holds_pending && holds_pending > 0 %]
-                                        <li><a href="/cgi-bin/koha/opac-user.pl#opac-user-holds"><span class="user_holds_pending_count count_label">[% holds_pending | html %]</span> hold(s) pending</a></li>
+                                        <li>
+                                            <a href="/cgi-bin/koha/opac-user.pl#opac-user-holds">
+                                                <span class="user_holds_pending_count count_label">[% holds_pending | html %]</span>
+                                                [% tn('hold pending', 'holds pending', holds_pending ) %]
+                                            </a>
+                                        </li>
                                     [% END %]
                                     [% IF holds_waiting && holds_waiting > 0 %]
-                                        <li><a href="/cgi-bin/koha/opac-user.pl#opac-user-holds"><span class="user_holds_waiting_count count_label">[% holds_waiting | html %]</span> hold(s) waiting</a></li>
+                                        <li>
+                                            <a href="/cgi-bin/koha/opac-user.pl#opac-user-holds">
+                                                <span class="user_holds_waiting_count count_label">[% holds_waiting | html %]</span>
+                                                [% tn('hold waiting', 'holds waiting', holds_waiting ) %]
+                                            </a>
+                                        </li>
                                     [% END %]
                                     [% IF total_owing && total_owing > 0 %]
-                                        <li><a href="/cgi-bin/koha/opac-account.pl"><span class="user_fines_count count_label">[% total_owing | $Price with_symbol => 1 %]</span> due in fines and charges</a></li>
+                                        <li>
+                                            <a href="/cgi-bin/koha/opac-account.pl">
+                                                <span class="user_fines_count count_label">[% total_owing | $Price with_symbol => 1 %]</span>
+                                                due in fines and charges
+                                            </a>
+                                        </li>
                                     [% END %]
                                     [% IF patron_messages && patron_messages.count > 0 || opacnote %]
                                         [% IF opacnote %]
-                                            <li><a href="/cgi-bin/koha/opac-user.pl"><span class="count_label">[% patron_messages.count + 1 | html %]</span> message(s)</a></li>
+                                            <li>
+                                                <a href="/cgi-bin/koha/opac-user.pl">
+                                                    <span class="count_label">[% patron_messages.count + 1 | html %]</span>
+                                                    [% tn('message', 'messages', patron_messages.count + 1 ) %]
+                                                </a>
+                                            </li>
                                         [% ELSE %]
-                                            <li><a href="/cgi-bin/koha/opac-user.pl"><span class="count_label">[% patron_messages.count | html %]</span> message(s)</a></li>
+                                            <li>
+                                                <a href="/cgi-bin/koha/opac-user.pl">
+                                                    <span class="count_label">[% patron_messages.count | html %]</span>
+                                                    [% tn('message', 'messages', patron_messages.count ) %]
+                                                </a>
+                                            </li>
                                         [% END %]
                                     [% END %]
                                 </ul>
-- 
2.11.0