From 8bb2a4057d7cb6aa6b028b21513b92139767615a Mon Sep 17 00:00:00 2001
From: Blou <blou@inlibro.com>
Date: Wed, 4 Dec 2019 11:49:01 -0500
Subject: [PATCH] Bug 24172: Allow translation of seasons in serials-edit.tt
and subscription-detail.tt
Seasons are not handled by locales. Those generated are stored in
English in the database, and the display in serials-collection.tt is
translating them. But once you click on "Edit serials" or if you go
straight to the subscription's display, those are displayed as in the
database: in English.
This patch reproduces the same trick as in serial-collection.tt and
allow for the display to be translated.
NOTE: this patch's testing require knowledge of translation tools.
Reproducing Caroline's test:
0- Make sure you have at least one language other than English installed
1- With staff interface in English, create a subscription with a seasonal numbering pattern and frequency, with locale in your other language
2- Check the prediction pattern, note that the season names are in English not the locale language
3- Change the staff interface to other language, redo the prediction pattern test with locale in other language, note that the season names are in other language
4- Save the subscription
5- Receive an issue, note that the season name in the "Numbered" column on serials-edit.pl is in English
6- Save your issue
7- Switch interface in other language
8- Note that the season name on serials-collection is in other language
9- If you check the database, you will see the season name is in English, even though the subscription.locale is something else
10- validate the different pages:
- serials-collection.pl: display is translated
- serials-edit.pl: name pulled directly from db
- subscription-detail.pl: name pulled directly from db
- detail.pl: name pulled directly from db
- opac-detail.pl: name pulled directly from db
11- APPLY THE PATCH
12- translate the string
a) ./translate update <some locale>
b) find the strings, translate them
c) ./translate install <same locale>
13- restart Plack ?
14- validate the pages again.
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Bug 24172: Allow translation of seasons in details.tt and opac-details.tt
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Bug 24172: Move duplicated code to an include file
---
.../prog/en/includes/localizer.inc | 21 +++++++++++++++++++
.../prog/en/modules/catalogue/detail.tt | 5 ++++-
.../en/modules/serials/serials-collection.tt | 21 ++-----------------
.../prog/en/modules/serials/serials-edit.tt | 5 ++++-
.../modules/serials/showpredictionpattern.tt | 21 ++-----------------
.../en/modules/serials/subscription-detail.tt | 3 ++-
.../bootstrap/en/modules/opac-detail.tt | 5 ++++-
7 files changed, 39 insertions(+), 42 deletions(-)
create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/localizer.inc
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/localizer.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/localizer.inc
new file mode 100644
index 0000000000..864dbc276f
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/localizer.inc
@@ -0,0 +1,21 @@
+[%~ BLOCK localize_numbering_pattern_season ~%]
+ [%~ IF ( matches = season.match('(.*)Spring(.*)') ) ~%]
+ [%~ matches.0 | html ~%]Spring[%~ matches.1 | html ~%]
+ [%~ ELSIF ( matches = season.match('(.*)Summer(.*)') ) ~%]
+ [%~ matches.0 | html ~%]Summer[%~ matches.1 | html ~%]
+ [%~ ELSIF ( matches = season.match('(.*)Fall(.*)') ) ~%]
+ [%~ matches.0 | html ~%]Fall[%~ matches.1 | html ~%]
+ [%~ ELSIF ( matches = season.match('(.*)Winter(.*)') ) ~%]
+ [%~ matches.0 | html ~%]Winter[%~ matches.1 | html ~%]
+ [%~ ELSIF ( matches = season.match('(.*)Spr(.*)') ) ~%]
+ [%~ matches.0 | html ~%]Spr[%~ matches.1 | html ~%]
+ [%~ ELSIF ( matches = season.match('(.*)Sum(.*)') ) ~%]
+ [%~ matches.0 | html ~%]Sum[%~ matches.1 | html ~%]
+ [%~ ELSIF ( matches = season.match('(.*)Fal(.*)') ) ~%]
+ [%~ matches.0 | html ~%]Fal[%~ matches.1 | html ~%]
+ [%~ ELSIF ( matches = season.match('(.*)Win(.*)') ) ~%]
+ [%~ matches.0 | html ~%]Win[%~ matches.1 | html ~%]
+ [%~ ELSE ~%]
+ [%~ season | html ~%]
+ [%~ END ~%]
+[%~ END ~%]
\ No newline at end of file
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
index f48413a010..084c27e022 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
@@ -8,6 +8,7 @@
[% USE Biblio %]
[% USE Price %]
[% USE TablesSettings %]
+[% PROCESS 'localizer.inc' %]
[% PROCESS 'i18n.inc' %]
[% IF Koha.Preference('AmazonAssocTag') %]
@@ -790,7 +791,9 @@ Note that permanent location is a code, and location may be an authval.
</tr>
[% FOREACH latestserial IN subscription.latestserials %]
<tr>
- <td>[% latestserial.serialseq | html %]</td>
+ <td>
+ [% PROCESS localize_numbering_pattern_season season => latestserial.serialseq %]
+ </td>
<td data-order="[% latestserial.planneddate | html %]">[% latestserial.planneddate | $KohaDates %]</td>
<td data-order="[% latestserial.publisheddate | html %]">[% latestserial.publisheddate | $KohaDates %]</td>
<td>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt
index 2e7196f69a..a9a720c06b 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt
@@ -3,6 +3,7 @@
[% USE AuthorisedValues %]
[% USE Branches %]
[% USE KohaDates %]
+[% PROCESS 'localizer.inc' %]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Serial collection information for [% bibliotitle | html %] › Serials › Koha</title>
@@ -246,25 +247,7 @@
[% END %]
</td>
<td>
- [% IF ( matches = serial.serialseq.match('(.*)Spring(.*)') ) %]
- [% matches.0 | html %]Spring[% matches.1 | html %]
- [% ELSIF ( matches = serial.serialseq.match('(.*)Summer(.*)') ) %]
- [% matches.0 | html %]Summer[% matches.1 | html %]
- [% ELSIF ( matches = serial.serialseq.match('(.*)Fall(.*)') ) %]
- [% matches.0 | html %]Fall[% matches.1 | html %]
- [% ELSIF ( matches = serial.serialseq.match('(.*)Winter(.*)') ) %]
- [% matches.0 | html %]Winter[% matches.1 | html %]
- [% ELSIF ( matches = prediction.number.match('(.*)Spr(.*)') ) %]
- [% matches.0 | html %]Spr[% matches.1 | html %]
- [% ELSIF ( matches = prediction.number.match('(.*)Sum(.*)') ) %]
- [% matches.0 | html %]Sum[% matches.1 | html %]
- [% ELSIF ( matches = prediction.number.match('(.*)Fal(.*)') ) %]
- [% matches.0 | html %]Fal[% matches.1 | html %]
- [% ELSIF ( matches = prediction.number.match('(.*)Win(.*)') ) %]
- [% matches.0 | html %]Win[% matches.1 | html %]
- [% ELSE %]
- [% serial.serialseq | html %]
- [% END %]
+ [% PROCESS localize_numbering_pattern_season season => serial.serialseq %]
</td>
<td>
[% IF ( serial.status1 ) %]<span>Expected</span>[% END %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt
index 881c857b2a..e479d3d590 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt
@@ -1,6 +1,7 @@
[% USE raw %]
[% USE Asset %]
[% USE AuthorisedValues %]
+[% PROCESS 'localizer.inc' %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Serial edition [% bibliotitle | html %] › Serials › Koha</title>
[% INCLUDE 'doc-head-close.inc' %]
@@ -139,7 +140,9 @@ $(document).ready(function() {
<input type="hidden" name="biblionumber" value="[% serialslis.biblionumber | html %]" />
<input type="hidden" name="itemcount" value="[% serialslis.issuesatonce | html %]" />
<input type="hidden" name="user" value="[% serialslis.librarian | html %]" />
- Issue <input type="text" name="serialseq" id="serialseq[% serialslis.serialid | html %]" value="[% serialslis.serialseq | html %]" size="20" maxlength="100" />
+ Issue <input type="text" name="serialseq" id="serialseq[% serialslis.serialid | html %]"
+ value="[% PROCESS localize_numbering_pattern_season season => serialslis.serialseq %]"
+ size="20" maxlength="100" />
</td>
<td>
<input type="text" name="publisheddate" value="[% serialslis.publisheddate | html %]" size="10" maxlength="15" class="flatpickr" />
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/showpredictionpattern.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/showpredictionpattern.tt
index ea6e6ab46d..255c90363c 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/showpredictionpattern.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/showpredictionpattern.tt
@@ -1,4 +1,5 @@
[% USE KohaDates %]
+[% PROCESS 'localizer.inc' %]
<h2>Prediction pattern</h2>
[% IF (not_consistent_end_date) %]
<p><em>End date is not consistent with subscription length.</em></p>
@@ -41,25 +42,7 @@
[% FOREACH prediction IN predictions_loop %]
<tr>
<td>
- [% IF ( matches = prediction.number.match('(.*)Spring(.*)') ) %]
- [% matches.0 | html %]Spring[% matches.1 | html %]
- [% ELSIF ( matches = prediction.number.match('(.*)Summer(.*)') ) %]
- [% matches.0 | html %]Summer[% matches.1 | html %]
- [% ELSIF ( matches = prediction.number.match('(.*)Fall(.*)') ) %]
- [% matches.0 | html %]Fall[% matches.1 | html %]
- [% ELSIF ( matches = prediction.number.match('(.*)Winter(.*)') ) %]
- [% matches.0 | html %]Winter[% matches.1 | html %]
- [% ELSIF ( matches = prediction.number.match('(.*)Spr(.*)') ) %]
- [% matches.0 | html %]Spr[% matches.1 | html %]
- [% ELSIF ( matches = prediction.number.match('(.*)Sum(.*)') ) %]
- [% matches.0 | html %]Sum[% matches.1 | html %]
- [% ELSIF ( matches = prediction.number.match('(.*)Fal(.*)') ) %]
- [% matches.0 | html %]Fal[% matches.1 | html %]
- [% ELSIF ( matches = prediction.number.match('(.*)Win(.*)') ) %]
- [% matches.0 | html %]Win[% matches.1 | html %]
- [% ELSE %]
- [% prediction.number | html %]
- [% END %]
+ [% PROCESS localize_numbering_pattern_season season => prediction.number %]
</td>
<td>
[% IF (prediction.publicationdate) %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt
index ee7d25a256..38830f949f 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt
@@ -7,6 +7,7 @@
[% USE Price %]
[% USE TablesSettings %]
[% SET footerjs = 1 %]
+[% PROCESS 'localizer.inc' %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Details for subscription #[% subscriptionid | html %] › Serials › Koha</title>
[% INCLUDE 'doc-head-close.inc' %]
@@ -336,7 +337,7 @@
[% FOREACH serialslis IN serialslist %]
<tr>
<td>
- [% serialslis.serialseq | html %]
+ [% PROCESS localize_numbering_pattern_season season => serialslis.serialseq %]
</td>
<td>
[% IF serialslis.planneddate %]
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt
index e69c3fac73..6522b43816 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt
@@ -6,6 +6,7 @@
[% USE Branches %]
[% USE TablesSettings %]
[% USE AuthorisedValues %]
+[% PROCESS 'localizer.inc' %]
[% SET TagsShowEnabled = ( ( Koha.Preference( 'TagsEnabled' ) == 1 ) && TagsShowOnDetail ) %]
[% SET TagsInputEnabled = ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) && ( Koha.Preference( 'TagsEnabled' ) == 1 ) && TagsInputOnDetail ) %]
[% IF Koha.Preference('AmazonAssocTag') %]
@@ -761,7 +762,9 @@
<tbody>
[% FOREACH latestserial IN subscription.latestserials %]
<tr>
- <td class="serialseq">[% latestserial.serialseq | html %]</td>
+ <td class="serialseq">
+ [% PROCESS localize_numbering_pattern_season season => latestserial.serialseq %]
+ </td>
<td class="publisheddate" data-order="[% latestserial.publisheddate | html %]">[% latestserial.publisheddate | $KohaDates %]</td>
<td class="planneddate" data-order="[% latestserial.planneddate | html %]">[% latestserial.planneddate | $KohaDates %]</td>
<td class="serial_status">
--
2.25.1