From c32545335b89dd951704419c9e03122855529c03 Mon Sep 17 00:00:00 2001 From: Shi Yao Wang Date: Thu, 25 Aug 2022 16:53:35 -0400 Subject: [PATCH] Bug 24172: Move duplicated code to an include file --- .../prog/en/includes/localizer.inc | 21 +++++++++++++++++++ .../prog/en/modules/catalogue/detail.tt | 21 ++----------------- .../en/modules/serials/serials-collection.tt | 21 ++----------------- .../prog/en/modules/serials/serials-edit.tt | 3 ++- .../modules/serials/showpredictionpattern.tt | 21 ++----------------- .../en/modules/serials/subscription-detail.tt | 21 ++----------------- .../bootstrap/en/modules/opac-detail.tt | 21 ++----------------- 7 files changed, 33 insertions(+), 96 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 e1b0455681..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') %] @@ -791,25 +792,7 @@ Note that permanent location is a code, and location may be an authval. [% FOREACH latestserial IN subscription.latestserials %] - [% IF ( matches = latestserial.serialseq.match('(.*)Spring(.*)') ) %] - [% matches.0 | html %]Spring[% matches.1 | html %] - [% ELSIF ( matches = latestserial.serialseq.match('(.*)Summer(.*)') ) %] - [% matches.0 | html %]Summer[% matches.1 | html %] - [% ELSIF ( matches = latestserial.serialseq.match('(.*)Fall(.*)') ) %] - [% matches.0 | html %]Fall[% matches.1 | html %] - [% ELSIF ( matches = latestserial.serialseq.match('(.*)Winter(.*)') ) %] - [% matches.0 | html %]Winter[% matches.1 | html %] - [% ELSIF ( matches = latestserial.serialseq.match('(.*)Spr(.*)') ) %] - [% matches.0 | html %]Spr[% matches.1 | html %] - [% ELSIF ( matches = latestserial.serialseq.match('(.*)Sum(.*)') ) %] - [% matches.0 | html %]Sum[% matches.1 | html %] - [% ELSIF ( matches = latestserial.serialseq.match('(.*)Fal(.*)') ) %] - [% matches.0 | html %]Fal[% matches.1 | html %] - [% ELSIF ( matches = latestserial.serialseq.match('(.*)Win(.*)') ) %] - [% matches.0 | html %]Win[% matches.1 | html %] - [% ELSE %] - [% latestserial.serialseq | html %] - [% END %] + [% PROCESS localize_numbering_pattern_season season => latestserial.serialseq %] [% latestserial.planneddate | $KohaDates %] [% latestserial.publisheddate | $KohaDates %] 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' %] Serial collection information for [% bibliotitle | html %] › Serials › Koha @@ -246,25 +247,7 @@ [% END %] - [% 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 %] [% IF ( serial.status1 ) %]Expected[% 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 05d7b47fa1..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' %] Serial edition [% bibliotitle | html %] › Serials › Koha [% INCLUDE 'doc-head-close.inc' %] @@ -140,7 +141,7 @@ $(document).ready(function() { Issue 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' %]

Prediction pattern

[% IF (not_consistent_end_date) %]

End date is not consistent with subscription length.

@@ -41,25 +42,7 @@ [% FOREACH prediction IN predictions_loop %] - [% 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 %] [% 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 30b2de7e71..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' %] Details for subscription #[% subscriptionid | html %] › Serials › Koha [% INCLUDE 'doc-head-close.inc' %] @@ -336,25 +337,7 @@ [% FOREACH serialslis IN serialslist %] - [% IF ( matches = serialslis.serialseq.match('(.*)Spring(.*)') ) %] - [% matches.0 | html %]Spring[% matches.1 | html %] - [% ELSIF ( matches = serialslis.serialseq.match('(.*)Summer(.*)') ) %] - [% matches.0 | html %]Summer[% matches.1 | html %] - [% ELSIF ( matches = serialslis.serialseq.match('(.*)Fall(.*)') ) %] - [% matches.0 | html %]Fall[% matches.1 | html %] - [% ELSIF ( matches = serialslis.serialseq.match('(.*)Winter(.*)') ) %] - [% matches.0 | html %]Winter[% matches.1 | html %] - [% ELSIF ( matches = serialslis.serialseq.match('(.*)Spr(.*)') ) %] - [% matches.0 | html %]Spr[% matches.1 | html %] - [% ELSIF ( matches = serialslis.serialseq.match('(.*)Sum(.*)') ) %] - [% matches.0 | html %]Sum[% matches.1 | html %] - [% ELSIF ( matches = serialslis.serialseq.match('(.*)Fal(.*)') ) %] - [% matches.0 | html %]Fal[% matches.1 | html %] - [% ELSIF ( matches = serialslis.serialseq.match('(.*)Win(.*)') ) %] - [% matches.0 | html %]Win[% matches.1 | html %] - [% ELSE %] - [% serialslis.serialseq | html %] - [% END %] + [% PROCESS localize_numbering_pattern_season season => serialslis.serialseq %] [% 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 0ddbdd49a1..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') %] @@ -762,25 +763,7 @@ [% FOREACH latestserial IN subscription.latestserials %] - [% IF ( matches = latestserial.serialseq.match('(.*)Spring(.*)') ) %] - [% matches.0 | html %]Spring[% matches.1 | html %] - [% ELSIF ( matches = latestserial.serialseq.match('(.*)Summer(.*)') ) %] - [% matches.0 | html %]Summer[% matches.1 | html %] - [% ELSIF ( matches = latestserial.serialseq.match('(.*)Fall(.*)') ) %] - [% matches.0 | html %]Fall[% matches.1 | html %] - [% ELSIF ( matches = latestserial.serialseq.match('(.*)Winter(.*)') ) %] - [% matches.0 | html %]Winter[% matches.1 | html %] - [% ELSIF ( matches = latestserial.serialseq.match('(.*)Spr(.*)') ) %] - [% matches.0 | html %]Spr[% matches.1 | html %] - [% ELSIF ( matches = latestserial.serialseq.match('(.*)Sum(.*)') ) %] - [% matches.0 | html %]Sum[% matches.1 | html %] - [% ELSIF ( matches = latestserial.serialseq.match('(.*)Fal(.*)') ) %] - [% matches.0 | html %]Fal[% matches.1 | html %] - [% ELSIF ( matches = latestserial.serialseq.match('(.*)Win(.*)') ) %] - [% matches.0 | html %]Win[% matches.1 | html %] - [% ELSE %] - [% latestserial.serialseq | html %] - [% END %] + [% PROCESS localize_numbering_pattern_season season => latestserial.serialseq %] [% latestserial.publisheddate | $KohaDates %] [% latestserial.planneddate | $KohaDates %] -- 2.25.1