From f7f41004340bbcce117debfcca0d46dc947f4af2 Mon Sep 17 00:00:00 2001 From: Blou 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 b) find the strings, translate them c) ./translate install 13- restart Plack ? 14- validate the pages again. Signed-off-by: Martin Renvoize Bug 24172: Allow translation of seasons in details.tt and opac-details.tt Signed-off-by: Martin Renvoize Bug 24172: Move duplicated code to an include file --- .../prog/en/includes/localizer.inc | 21 +++++++++++++++++++ .../prog/en/modules/catalogue/detail.tt | 3 ++- .../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, 37 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 d465aca384..6121e0c03b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -10,6 +10,7 @@ [% USE Frameworks %] [% USE Price %] [% USE TablesSettings %] +[% PROCESS 'localizer.inc' %] [% PROCESS 'i18n.inc' %] [% PROCESS 'html_helpers/tables/items/catalogue_detail.inc' %] [% SET CoverImagePlugins = KohaPlugins.get_plugins_intranet_cover_images %] @@ -534,7 +535,7 @@ [% FOREACH latestserial IN subscription.latestserials %] - [% latestserial.serialseq | html %] + [% PROCESS localize_numbering_pattern_season season => latestserial.serialseq %] [% latestserial.planneddate | $KohaDates %] [% latestserial.publisheddate | $KohaDates %] [% latestserial.publisheddatetext | html %] 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 7d3b57beee..a65d05e9bb 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 @@ -5,6 +5,7 @@ [% USE HtmlTags %] [% USE KohaDates %] [% PROCESS 'i18n.inc' %] +[% PROCESS 'localizer.inc' %] [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] [% FILTER collapse %] @@ -283,25 +284,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> [% INCLUDE 'serial-status.inc' serial = serial %] 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 644ce9d111..fcc19e4022 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 @@ -2,6 +2,7 @@ [% USE Asset %] [% USE AuthorisedValues %] [% PROCESS 'i18n.inc' %] +[% PROCESS 'localizer.inc' %] [% INCLUDE 'doc-head-open.inc' %] <title>[% FILTER collapse %] [% t("Serial edition") | html %] @@ -159,7 +160,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 7aed47a977..36fcb0e262 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 @@ -10,6 +10,7 @@ [% PROCESS 'i18n.inc' %] [% SET footerjs = 1 %] [%- PROCESS 'html_helpers.inc' -%] +[% PROCESS 'localizer.inc' %] [% INCLUDE 'doc-head-open.inc' %] <title>[% FILTER collapse %] [% t("Subscription details") | html %] › @@ -270,7 +271,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 03acede510..c9caad342d 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -7,6 +7,7 @@ [% USE TablesSettings %] [% USE AuthorisedValues %] [% USE KohaPlugins %] +[% PROCESS 'localizer.inc' %] [% SET TagsShowEnabled = ( ( Koha.Preference( 'TagsEnabled' ) == 1 ) && TagsShowOnDetail ) %] [% SET TagsInputEnabled = ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) && ( Koha.Preference( 'TagsEnabled' ) == 1 ) && TagsInputOnDetail ) %] [% SET CoverImagePlugins = KohaPlugins.get_plugins_opac_cover_images %] @@ -763,7 +764,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.34.1