Bugzilla – Attachment 179836 Details for
Bug 35590
Add the translation of seasonal predictions for a chosen locale
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35590: Translate the seasons when testing the numbering pattern with a selected locale
Bug-35590-Translate-the-seasons-when-testing-the-n.patch (text/plain), 60.73 KB, created by
William Lavoie
on 2025-03-28 15:24:59 UTC
(
hide
)
Description:
Bug 35590: Translate the seasons when testing the numbering pattern with a selected locale
Filename:
MIME Type:
Creator:
William Lavoie
Created:
2025-03-28 15:24:59 UTC
Size:
60.73 KB
patch
obsolete
>From 11fbb204b195d32cd1f46101c35736b5420336fa Mon Sep 17 00:00:00 2001 >From: Emily-Rose Francoeur <emily-rose.francoeur@inLibro.com> >Date: Tue, 19 Dec 2023 08:49:23 -0500 >Subject: [PATCH] Bug 35590: Translate the seasons when testing the numbering > pattern with a selected locale >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patch allows you to test a numbering pattern that uses seasons or their abbreviations with the locale of your choice. Since DateTime() cannot handle translations for seasons, the patch relies on the translations in the .po files. Therefore, you need to have the .po file installed if you want to test this patch. > >TEST PLAN > >Prequisites: >Install the .po files for at least one language other than the one used in your staff interface (these files should be added to the misc/translator/po/ folder). Ensure that translations for seasons (Spring, Summer, Fall, and Winter) and their abbreviations (Spr, Sum, Fal, and Win) exist (these should be in the *-staff-prog.po). In my case, I use the .po files for French Canadian translations (fr-CA) because the translations for seasons and their abbreviations already exist. > >1) Apply the patch. >2) Navigate to "Serials > Manage numbering patterns" and click on the "Edit" button for the "Seasonal" pattern. >3) Under "Test prediction pattern": > - Set "First issue publication date" to today's date. > - Set "Subscription length" to "issues" and input "4". > - Choose the language you previously installed for "Locale" (in my case, it's "Français (French)"). > - Set "Begins with" to 0 (for X) and 2023 (for Y). >4) Click on the "Test pattern" button. > - Observe that the season names are displayed in the other language ("Printemps Ãté Automne Hiver" for me). >5) In the first section of the page, within the table, change "Formatting" to "Name of season (abbreviated)". >6) Click on the "Test pattern" button. > - Observe that the season abbreviated names are displayed in the other language ("Pri Ãté Aut Hiv" for me). >7) Navigate to a record detail page and click on "+ New" and then "New subscription". >8) Click on the "Next ->" button and then "OK". >9) Fill in the following fields: > - Set "First issue publication date" to today's date. > - Set "Frequency" to your preference. > - Set "Subscription length" to "issues" and input "4". > - Set "Subscription start date" to today's date. > - Select "Seasonal" for "Numbering pattern". > - Choose a language different from the one used in the staff interface for "Locale" (any language except English). > - Set "Begins with" to 0 (for Season) and 2023 (for Year). >10) Click on the "Test pattern" button. > - Observe that the season names are displayed in the other language ("Printemps Ãté Automne Hiver" for me). >11) Run the unit tests for Serials and GetNextSeq > - prove ./t/db_dependent/Serials.t > - prove ./t/db_dependent/Serials/GetNextSeq.t >--- > C4/Serials.pm | 182 +++++++++--- > .../modules/serials/showpredictionpattern.tt | 38 ++- > .../en/modules/serials/subscription-add.tt | 258 ++++++++++++++++++ > .../serials/subscription-numberpatterns.tt | 130 +++++---- > .../intranet-tmpl/prog/js/subscription-add.js | 49 ++-- > serials/showpredictionpattern.pl | 21 +- > serials/subscription-add.pl | 1 + > serials/subscription-numberpatterns.pl | 1 + > t/db_dependent/Serials.t | 82 +++++- > t/db_dependent/Serials/GetNextSeq.t | 1 + > 10 files changed, 615 insertions(+), 148 deletions(-) > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index 39853a878b..d0269ff3c7 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -50,6 +50,8 @@ use Koha::Subscription::Routinglists; > use Koha::Subscriptions; > use Koha::Suggestions; > use Koha::TemplateUtils qw( process_tt ); >+use List::Util qw( first ); >+use Locale::PO; > > # Define statuses > use constant { >@@ -108,6 +110,7 @@ BEGIN { > > findSerialsByStatus > >+ GetSeasonsTranslations > ); > } > >@@ -319,22 +322,22 @@ sub GetFullSubscription { > my $query = qq| > SELECT serial.serialid, > serial.serialseq, >- serial.planneddate, >- serial.publisheddate, >+ serial.planneddate, >+ serial.publisheddate, > serial.publisheddatetext, >- serial.status, >+ serial.status, > serial.notes as notes, > year(IF(serial.publisheddate IS NULL,serial.planneddate,serial.publisheddate)) as year, > aqbooksellers.name as aqbooksellername, > biblio.title as bibliotitle, > subscription.branchcode AS branchcode, > subscription.subscriptionid AS subscriptionid >- FROM serial >- LEFT JOIN subscription ON >+ FROM serial >+ LEFT JOIN subscription ON > (serial.subscriptionid=subscription.subscriptionid ) >- LEFT JOIN aqbooksellers on subscription.aqbooksellerid=aqbooksellers.id >- LEFT JOIN biblio on biblio.biblionumber=subscription.biblionumber >- WHERE serial.subscriptionid = ? >+ LEFT JOIN aqbooksellers on subscription.aqbooksellerid=aqbooksellers.id >+ LEFT JOIN biblio on biblio.biblionumber=subscription.biblionumber >+ WHERE serial.subscriptionid = ? > ORDER BY year DESC, > IF(serial.publisheddate IS NULL,serial.planneddate,serial.publisheddate) DESC, > serial.subscriptionid >@@ -460,22 +463,22 @@ sub GetFullSubscriptionsFromBiblionumber { > my $query = qq| > SELECT serial.serialid, > serial.serialseq, >- serial.planneddate, >- serial.publisheddate, >+ serial.planneddate, >+ serial.publisheddate, > serial.publisheddatetext, >- serial.status, >+ serial.status, > serial.notes as notes, > year(IF(serial.publisheddate IS NULL,serial.planneddate,serial.publisheddate)) as year, > biblio.title as bibliotitle, > subscription.branchcode AS branchcode, > subscription.subscriptionid AS subscriptionid, > subscription.location AS location >- FROM serial >- LEFT JOIN subscription ON >+ FROM serial >+ LEFT JOIN subscription ON > (serial.subscriptionid=subscription.subscriptionid) >- LEFT JOIN aqbooksellers on subscription.aqbooksellerid=aqbooksellers.id >- LEFT JOIN biblio on biblio.biblionumber=subscription.biblionumber >- WHERE subscription.biblionumber = ? >+ LEFT JOIN aqbooksellers on subscription.aqbooksellerid=aqbooksellers.id >+ LEFT JOIN biblio on biblio.biblionumber=subscription.biblionumber >+ WHERE subscription.biblionumber = ? > ORDER BY year DESC, > IF(serial.publisheddate IS NULL,serial.planneddate,serial.publisheddate) DESC, > serial.subscriptionid >@@ -726,7 +729,7 @@ sub GetSerials2 { > my $query = q| > SELECT serialid,serialseq, status, planneddate, publisheddate, > publisheddatetext, notes, routingnotes >- FROM serial >+ FROM serial > WHERE subscriptionid=? > | > . q| AND status IN (| . join( ",", ('?') x @$statuses ) . q|)| . q| >@@ -861,6 +864,7 @@ sub GetNextSeq { > $newinnerloop1 = $subscription->{innerloop1} || 0; > $newinnerloop2 = $subscription->{innerloop2} || 0; > $newinnerloop3 = $subscription->{innerloop3} || 0; >+ my $translations = $subscription->{translations}; > my %calc; > > foreach (qw/X Y Z/) { >@@ -905,16 +909,16 @@ sub GetNextSeq { > $newlastvalue3 = $pattern->{setto3} if ( $newlastvalue3 > $pattern->{whenmorethan3} ); > } > } >- if ( $calc{'X'} ) { >- my $newlastvalue1string = _numeration( $newlastvalue1, $pattern->{numbering1}, $locale ); >+ if($calc{'X'}) { >+ my $newlastvalue1string = _numeration( $newlastvalue1, $pattern->{numbering1}, $locale, $translations ); > $calculated =~ s/\{X\}/$newlastvalue1string/g; > } >- if ( $calc{'Y'} ) { >- my $newlastvalue2string = _numeration( $newlastvalue2, $pattern->{numbering2}, $locale ); >+ if($calc{'Y'}) { >+ my $newlastvalue2string = _numeration( $newlastvalue2, $pattern->{numbering2}, $locale, $translations ); > $calculated =~ s/\{Y\}/$newlastvalue2string/g; > } >- if ( $calc{'Z'} ) { >- my $newlastvalue3string = _numeration( $newlastvalue3, $pattern->{numbering3}, $locale ); >+ if($calc{'Z'}) { >+ my $newlastvalue3string = _numeration( $newlastvalue3, $pattern->{numbering3}, $locale, $translations ); > $calculated =~ s/\{Z\}/$newlastvalue3string/g; > } > >@@ -952,21 +956,20 @@ sub GetSeq { > > my $locale = $subscription->{locale}; > >+ my $translations = $subscription->{translations}; >+ > my $calculated = $pattern->{numberingmethod}; > > my $newlastvalue1 = $subscription->{'lastvalue1'} || 0; >- $newlastvalue1 = _numeration( $newlastvalue1, $pattern->{numbering1}, $locale ) >- if ( $pattern->{numbering1} ); # reset counter if needed. >+ $newlastvalue1 = _numeration($newlastvalue1, $pattern->{numbering1}, $locale, $translations) if ($pattern->{numbering1}); # reset counter if needed. > $calculated =~ s/\{X\}/$newlastvalue1/g; > > my $newlastvalue2 = $subscription->{'lastvalue2'} || 0; >- $newlastvalue2 = _numeration( $newlastvalue2, $pattern->{numbering2}, $locale ) >- if ( $pattern->{numbering2} ); # reset counter if needed. >+ $newlastvalue2 = _numeration($newlastvalue2, $pattern->{numbering2}, $locale, $translations) if ($pattern->{numbering2}); # reset counter if needed. > $calculated =~ s/\{Y\}/$newlastvalue2/g; > > my $newlastvalue3 = $subscription->{'lastvalue3'} || 0; >- $newlastvalue3 = _numeration( $newlastvalue3, $pattern->{numbering3}, $locale ) >- if ( $pattern->{numbering3} ); # reset counter if needed. >+ $newlastvalue3 = _numeration($newlastvalue3, $pattern->{numbering3}, $locale, $translations) if ($pattern->{numbering3}); # reset counter if needed. > $calculated =~ s/\{Z\}/$newlastvalue3/g; > > my $dt = dt_from_string( $subscription->{firstacquidate} ); >@@ -1072,7 +1075,7 @@ sub ModSubscriptionHistory { > return unless ($subscriptionid); > > my $dbh = C4::Context->dbh; >- my $query = "UPDATE subscriptionhistory >+ my $query = "UPDATE subscriptionhistory > SET histstartdate=?,histenddate=?,recievedlist=?,missinglist=?,opacnote=?,librariannote=? > WHERE subscriptionid=? > "; >@@ -1279,7 +1282,7 @@ sub GetNextExpected { > ModNextExpected($subscriptionid,$date) > > Update the planneddate for the current expected issue of the subscription. >-This will modify all future prediction results. >+This will modify all future prediction results. > > C<$date> is an ISO date. > >@@ -1582,7 +1585,7 @@ sub ReNewSubscription { > my $subscription = GetSubscription($subscriptionid); > my $query = qq| > SELECT * >- FROM biblio >+ FROM biblio > LEFT JOIN biblioitems ON biblio.biblionumber=biblioitems.biblionumber > WHERE biblio.biblionumber=? > |; >@@ -1719,7 +1722,7 @@ sub NewIssue { > > 1 or 0 = HasSubscriptionStrictlyExpired($subscriptionid) > >-the subscription has stricly expired when today > the end subscription date >+the subscription has stricly expired when today > the end subscription date > > return : > 1 if true, 0 if false, -1 if the expiration date is not set. >@@ -1907,7 +1910,7 @@ sub DelIssue { > this function selects missing issues on database - where serial.status = MISSING* or serial.status = LATE or planneddate<now > > return : >-the issuelist as an array of hash refs. Each element of this array contains >+the issuelist as an array of hash refs. Each element of this array contains > name,title,planneddate,serialseq,serial.subscriptionid from tables : subscription, serial & biblio > > =cut >@@ -2040,7 +2043,7 @@ sub check_routing { > > my $dbh = C4::Context->dbh; > my $sth = $dbh->prepare( >- "SELECT count(routingid) routingids FROM subscription LEFT JOIN subscriptionroutinglist >+ "SELECT count(routingid) routingids FROM subscription LEFT JOIN subscriptionroutinglist > ON subscription.subscriptionid = subscriptionroutinglist.subscriptionid > WHERE subscription.subscriptionid = ? GROUP BY routingid ORDER BY ranking ASC > " >@@ -2172,7 +2175,7 @@ sub getroutinglist { > my $dbh = C4::Context->dbh; > my $sth = $dbh->prepare( > 'SELECT routingid, borrowernumber, ranking, biblionumber >- FROM subscription >+ FROM subscription > JOIN subscriptionroutinglist ON subscription.subscriptionid = subscriptionroutinglist.subscriptionid > WHERE subscription.subscriptionid = ? ORDER BY ranking ASC' > ); >@@ -2240,7 +2243,7 @@ sub HasItems { > my $dbh = C4::Context->dbh; > my $query = q| > SELECT COUNT(serialitems.itemnumber) >- FROM serial >+ FROM serial > LEFT JOIN serialitems USING(serialid) > WHERE subscriptionid=? AND serialitems.serialid IS NOT NULL > |; >@@ -2606,7 +2609,7 @@ num_type can take : > =cut > > sub _numeration { >- my ( $value, $num_type, $locale ) = @_; >+ my ($value, $num_type, $locale, $translations) = @_; > $value ||= 0; > $num_type //= ''; > $locale ||= 'en'; >@@ -2637,13 +2640,11 @@ sub _numeration { > ? $dt->format_cldr("LLLL") > : $dt->strftime("%b"); > } elsif ( $num_type =~ /^season$/ ) { >- my @seasons = qw( Spring Summer Fall Winter ); >- $value = $value % 4; >- $string = $seasons[$value]; >+ $value = $value % 4; >+ $string = $translations->{seasons}->[$value]; > } elsif ( $num_type =~ /^seasonabrv$/ ) { >- my @seasonsabrv = qw( Spr Sum Fal Win ); >- $value = $value % 4; >- $string = $seasonsabrv[$value]; >+ $value = $value % 4; >+ $string = $translations->{seasonsabrv}->[$value]; > } else { > $string = $value; > } >@@ -2713,6 +2714,58 @@ sub ReopenSubscription { > $sth->execute( EXPECTED, $subscriptionid, STOPPED ); > } > >+=head2 GetSeasonsTranslations >+ >+Provide translations for the seasons and their abbreviations for the specified locale >+ >+=cut >+ >+sub GetSeasonsTranslations { >+ my ( $need_seasons, $need_seasonsabrv, $subtag ) = @_; >+ my @seasons = qw( Spring Summer Fall Winter ); >+ my @seasonsabrv = qw( Spr Sum Fal Win ); >+ my @error_messages = qw(); >+ >+ my @dirs = ( >+ C4::Context->config('intranetdir') . '/misc/translator/po', >+ C4::Context->config('intranetdir') . '/../../misc/translator/po', >+ ); >+ >+ my $dir = first { -d } @dirs; >+ >+ if ($dir) { >+ my @po_paths = glob("$dir/$subtag*staff-prog.po"); >+ if (@po_paths) { >+ my $po_path = $po_paths[0]; >+ my $po_filename = ( $po_path =~ s/$dir\///gr ); >+ my $po_data = Locale::PO->load_file_ashash( $po_path, 'utf8' ); >+ >+ if ($need_seasons) { >+ my $response = _translate( $po_data, @seasons ); >+ @seasons = @{ $response->{translations} }; >+ @error_messages = >+ ( @error_messages, map { sprintf( $_, $po_filename ) } @{ $response->{error_messages} } ); >+ } >+ >+ if ($need_seasonsabrv) { >+ my $response = _translate( $po_data, @seasonsabrv ); >+ @seasonsabrv = @{ $response->{translations} }; >+ @error_messages = >+ ( @error_messages, map { sprintf( $_, $po_filename ) } @{ $response->{error_messages} } ); >+ } >+ } else { >+ push( >+ @error_messages, >+ "No translation file found for $subtag. Ensure that the translation files for $subtag are installed." >+ ); >+ } >+ } else { >+ push( @error_messages, "The PO directory has not been found. There is a problem in your Koha installation." ); >+ } >+ >+ return { seasons => \@seasons, seasonsabrv => \@seasonsabrv, error_messages => \@error_messages }; >+} >+ > =head2 subscriptionCurrentlyOnOrder > > $bool = subscriptionCurrentlyOnOrder( $subscriptionid ); >@@ -2803,6 +2856,47 @@ sub _can_do_on_subscription { > return 0; > } > >+=head2 _translate >+ >+Provide translations for the given words based on the provided data >+ >+=cut >+ >+sub _translate { >+ my ( $data, @words ) = @_; >+ >+ my @translations = qw(); >+ my @error_messages = qw(); >+ >+ for my $word (@words) { >+ my $regex = qr/^"$word"$|\%s$word\%s/; >+ my @msgids = grep /$regex/, keys %{$data}; >+ my $translation = ""; >+ >+ while ( ( $translation eq "" ) && ( my $msgid = shift(@msgids) ) ) { >+ next unless ( $data->{$msgid}->reference =~ /serials/ ); >+ my $msgstr = $data->{$msgid}->msgstr; >+ my @ids = split( /\%s/, $msgid ); >+ my @strs = split( /\%s/, $msgstr ); >+ >+ next unless ( scalar @ids == scalar @strs ); >+ >+ my $idx = first { $ids[$_] eq $word || $ids[$_] eq $msgid } 0 .. $#ids; >+ $translation = Locale::PO->dequote( $strs[$idx] ) if ( defined $idx ); >+ } >+ >+ if ( $translation eq "" ) { >+ push( @translations, $word ); >+ push( @error_messages, "The translation for $word doesn't exist in the file \%s" ); >+ next; >+ } >+ >+ push( @translations, $translation ); >+ } >+ >+ return { translations => \@translations, error_messages => \@error_messages }; >+} >+ > =head2 findSerialsByStatus > > @serials = findSerialsByStatus($status, $subscriptionid); >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 7522a9d7fc..bfd222c07a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/showpredictionpattern.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/showpredictionpattern.tt >@@ -78,8 +78,42 @@ > [% END %] > </tr> > [% END %] >- </tbody> >- </table> >+ </td> >+ <td> >+ [% IF (prediction.publicationdate) %] >+ [% prediction.publicationdate | $KohaDates %] >+ [% ELSE %] >+ <span>unknown</span> >+ [% END %] >+ </td> >+ [% IF (ask_for_irregularities) %] >+ <td style="text-align:center"> >+ [% UNLESS (loop.first) %] >+ [% IF (prediction.not_published) %] >+ <input type="checkbox" name="irregularity" value="[% prediction.issuenumber | html %]" data-dow="[% prediction.dow | html %]" checked="checked" /> >+ [% ELSE %] >+ <input type="checkbox" name="irregularity" value="[% prediction.issuenumber | html %]" data-dow="[% prediction.dow | html %]" /> >+ [% END %] >+ </td> >+ [% END %] >+ [% END %] >+ </tr> >+ [% END %] >+ </tbody> >+</table> >+ >+[% IF (error_messages) %] >+ <div class="alert alert-warning"> >+ <h4 class="alert-heading"><i class="bi-exclamation-triangle-fill"></i> Warning</h4> >+ [% FOREACH error_message IN error_messages %] >+ <p>[% error_message | html %]</p> >+ [% END %] >+ </div> >+[% END %] >+ >+<fieldset class="action"> >+ <button class="btn btn-default btn-sm" id="hidepredictionpattern">Done</button> >+</fieldset> > > <fieldset class="action"> > <button class="btn btn-default btn-sm" id="hidepredictionpattern">Done</button> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt >index 1e62a1108e..dee438b9bf 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt >@@ -540,6 +540,264 @@ > <button type="button" id="testpatternbutton" class="btn btn-default btn-sm"><i class="fa fa-play"></i> Test prediction pattern</button> > </fieldset> > </fieldset> >+ [% END %] >+ <div style="display:none" id="mana_search" class="alert alert-info"> >+ </div> >+ <div id="subscription_form_planning"> >+ <fieldset class="rows"> >+ <legend>Serials planning</legend> >+ <ol> >+ <li> >+ <label for="acqui_date" class="required">First issue publication date:</label> >+ [% UNLESS (more_than_one_serial) %] >+ <input type="text" size="10" id="acqui_date" name="firstacquidate" value="[% firstacquidate | html %]" class="flatpickr required" required="required" /> >+ [% ELSE %] >+ [% firstacquidate | $KohaDates %] >+ <input type="hidden" id="acqui_date" name="firstacquidate" value="[% firstacquidate | $KohaDates dateformat => 'iso' %]"/> >+ [% END %] >+ <span class="required">Required</span> >+ </li> >+ [% IF (more_than_one_serial) %] >+ <li> >+ <label for="nextacquidate">Next issue publication date:</label> >+ <input type="text" size="10" id="nextacquidate" name="nextacquidate" value="[% nextacquidate | html %]" class="flatpickr" /> >+ </li> >+ [% END %] >+ <li> >+ <label for="frequency" class="required">Frequency:</label> >+ <select name="frequency" id="frequency" class="required" required="required"> >+ <option value="">-- please choose --</option> >+ [% FOREACH frequency IN frequencies %] >+ [% IF (frequency.selected) %] >+ <option value="[% frequency.id | html %]" selected="selected"> >+ [% ELSE %] >+ <option value="[% frequency.id | html %]"> >+ [% END %] >+ [% frequency.label | html %] >+ </option> >+ [% END %] >+ </select> >+ </li> >+ <li> >+ <label for="subtype">Subscription length:</label> >+ <select name="subtype" id="subtype"> >+ [% FOREACH st IN subtypes %] >+ [% SWITCH st %] >+ [% CASE 'numberlength' %] >+ [% IF st == subtype %] >+ <option value="issues" selected="selected"> >+ [% ELSE %] >+ <option value="issues"> >+ [% END %] >+ issues >+ [% CASE 'weeklength' %] >+ [% IF st == subtype %] >+ <option value="weeks" selected="selected"> >+ [% ELSE %] >+ <option value="weeks"> >+ [% END %] >+ weeks >+ [% CASE 'monthlength' %] >+ [% IF st == subtype %] >+ <option value="months" selected="selected"> >+ [% ELSE %] >+ <option value="months"> >+ [% END %] >+ months >+ [% CASE %][% st | html %] >+ [% END %] >+ </option> >+ [% END %] >+ </select> >+ <input type="text" name="sublength" id="sublength" value="[% sublength | html %]" size="3" /> (enter amount in numerals) >+ <input type="hidden" name="issuelengthcount"> >+ </li> >+ <li> >+ <label for="from" class="required"> Subscription start date:</label> >+ <input type="text" size="10" id="from" name="startdate" value="[% startdate | html %]" class="flatpickr required" data-date_to="to" required="required" /> >+ </li> >+ <li> >+ <label for="to">Subscription end date:</label> >+ <input type="text" size="10" id="to" name="enddate" value="[% enddate | html %]" class="flatpickr" /> >+ </li> >+ <li> >+ <label for="numberpattern" class="required">Numbering pattern:</label> >+ <select name="numbering_pattern" id="numberpattern" class="required" required="required"> >+ <option value="">-- please choose --</option> >+ [% FOREACH numberpattern IN numberpatterns %] >+ [% IF (numberpattern.selected) %] >+ <option value="[% numberpattern.id | html %]" selected="selected"> >+ [% ELSE %] >+ <option value="[% numberpattern.id | html %]"> >+ [% END %] >+ [% numberpattern.label | html %] >+ </option> >+ [% END %] >+ </select> >+ <span class="required">Required</span> >+ </li> >+ <li> >+ <label for="published_on_template">Publication date template:</label> >+ <textarea id="published_on_template" name="published_on_template">[% published_on_template | html %]</textarea> >+ </li> >+ <li> >+ <label for="locale">Locale:</label> >+ <select id="locale" name="locale"> >+ <option value=""></option> >+ [% FOREACH l IN locales %] >+ [% IF l.language == locale %] >+ <option value="[% l.language | html %]" data-subtag="[% l.subtag | html %]" selected="selected">[% l.description | html %]</option> >+ [% ELSE %] >+ <option value="[% l.language | html %]" data-subtag="[% l.subtag | html %]">[% l.description | html %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ <input type="hidden" id="subtag" name="subtag" value=""> >+ <div class="hint">If empty, English is used</div> >+ </li> >+ <li id="more_options"> >+ <span class="label"> </span> >+ <table id="moreoptionst"> >+ <thead> >+ <tr> >+ <th> </th> >+ <th id="headerX"> </th> >+ <th id="headerY"> </th> >+ <th id="headerZ"> </th> >+ </tr> >+ </thead> >+ <tbody> >+ <tr> >+ <th scope="row"> >+ [% IF (more_than_one_serial) %] >+ Last value: >+ [% ELSE %] >+ Begins with: >+ [% END %] >+ </th> >+ <td id="beginsX"><input type="text" id="lastvaluetemp1" name="lastvaluetemp1" value="[% lastvalue1 | html %]" /></td> >+ <td id="beginsY"><input type="text" id="lastvaluetemp2" name="lastvaluetemp2" value="[% lastvalue2 | html %]" /></td> >+ <td id="beginsZ"><input type="text" id="lastvaluetemp3" name="lastvaluetemp3" value="[% lastvalue3 | html %]" /></td> >+ </tr> >+ <tr> >+ <th scope="row">Inner counter:</th> >+ <td id="innerX"><input type="text" id="innerlooptemp1" name="innerlooptemp1" value="[% innerloop1 | html %]" /></td> >+ <td id="innerY"><input type="text" id="innerlooptemp2" name="innerlooptemp2" value="[% innerloop2 | html %]" /></td> >+ <td id="innerZ"><input type="text" id="innerlooptemp3" name="innerlooptemp3" value="[% innerloop3 | html %]" /></td> >+ </tr> >+ </tbody> >+ </table> >+ </li> >+ <li> >+ <span class="label"> </span> >+ <a href="#" class="toggle_advanced_pattern show_advanced_pattern"><i class="fa fa-plus-square"></i> Show advanced pattern</a> >+ <a href="#" style="display:none;" class="toggle_advanced_pattern hide_advanced_pattern"><i class="fa fa-minus-square"></i> Hide advanced pattern</a> >+ </li> >+ </ol> >+ >+ <div id="advancedpredictionpattern" style="display:none"> >+ <ol> >+ <li> >+ <label for="patternname" class="required">Pattern name:</label> >+ <input id="patternname" name="patternname" type="text" readonly="readonly" class="required" required="required" /> >+ <span class="required">Required</span> >+ </li> >+ <li> >+ <label for="numberingmethod">Numbering formula:</label> >+ <input readonly="readonly" type="text" name="numberingmethod" id="numberingmethod" size="50" value="[% numberingmethod | html %]" /> >+ </li> >+ <li> >+ <span class="label">Advanced prediction pattern: </span> >+ <table id="advancedpredictionpatternt"> >+ <thead> >+ <tr> >+ <th> </th> >+ <th>X</th> >+ <th>Y</th> >+ <th>Z</th> >+ </tr> >+ </thead> >+ <tbody> >+ <tr> >+ <th scope="row">Label: </th> >+ <td><input type="text" readonly="readonly" id="label1" name="label1" /></td> >+ <td><input type="text" readonly="readonly" id="label2" name="label2" /></td> >+ <td><input type="text" readonly="readonly" id="label3" name="label3" /></td> >+ </tr> >+ <tr> >+ <th scope="row">Begins with: </th> >+ <td><input type="text" readonly="readonly" id="lastvalue1" name="lastvalue1" /></td> >+ <td><input type="text" readonly="readonly" id="lastvalue2" name="lastvalue2" /></td> >+ <td><input type="text" readonly="readonly" id="lastvalue3" name="lastvalue3" /></td> >+ </tr> >+ <tr> >+ <th scope="row">Add: </th> >+ <td><input type="text" readonly="readonly" id="add1" name="add1" /></td> >+ <td><input type="text" readonly="readonly" id="add2" name="add2" /></td> >+ <td><input type="text" readonly="readonly" id="add3" name="add3" /></td> >+ </tr> >+ <tr> >+ <th scope="row">Every: </th> >+ <td><input type="text" readonly="readonly" id="every1" name="every1" /></td> >+ <td><input type="text" readonly="readonly" id="every2" name="every2" /></td> >+ <td><input type="text" readonly="readonly" id="every3" name="every3" /></td> >+ </tr> >+ <tr> >+ <th scope="row">Set back to: </th> >+ <td><input type="text" readonly="readonly" id="setto1" name="setto1" /></td> >+ <td><input type="text" readonly="readonly" id="setto2" name="setto2" /></td> >+ <td><input type="text" readonly="readonly" id="setto3" name="setto3" /></td> >+ </tr> >+ <tr> >+ <th scope="row">When more than: </th> >+ <td><input type="text" readonly="readonly" id="whenmorethan1" name="whenmorethan1" /></td> >+ <td><input type="text" readonly="readonly" id="whenmorethan2" name="whenmorethan2" /></td> >+ <td><input type="text" readonly="readonly" id="whenmorethan3" name="whenmorethan3" /></td> >+ </tr> >+ <tr> >+ <th scope="row">Inner counter: </th> >+ <td><input type="text" readonly="readonly" id="innerloop1" name="innerloop1" /></td> >+ <td><input type="text" readonly="readonly" id="innerloop2" name="innerloop2" /></td> >+ <td><input type="text" readonly="readonly" id="innerloop3" name="innerloop3" /></td> >+ </tr> >+ <tr> >+ [% BLOCK numbering_select %] >+ <select disabled="disabled" id="[% name | html %]" name="[% name | html %]"> >+ <option value=""></option> >+ <option value="dayname">Name of day</option> >+ <option value="dayabrv">Name of day (abbreviated)</option> >+ <option value="monthname">Name of month</option> >+ <option value="monthabrv">Name of month (abbreviated)</option> >+ <option value="season">Name of season</option> >+ <option value="seasonabrv">Name of season (abbreviated)</option> >+ </select> >+ [% END %] >+ <th scope="row">Formatting:</th> >+ <td>[% PROCESS numbering_select name="numbering1" %]</td> >+ <td>[% PROCESS numbering_select name="numbering2" %]</td> >+ <td>[% PROCESS numbering_select name="numbering3" %]</td> >+ </tr> >+ </tbody> >+ </table> >+ </li> >+ <li> >+ <span class="label"> </span> >+ <a href="#" id="modifyadvancedpatternbutton"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Modify pattern</a> >+ <button type="button" class="btn btn-default btn-xs" id="saveadvancedpatternbutton" style="display:none"><i class="fa fa-save"></i> Save as new pattern</button> >+ <a class="cancel" href="#" id="restoreadvancedpatternbutton" style="display:none">Cancel modifications</a> >+ </li> >+ </ol> >+ </div> <!-- /#advancedpredictionpattern --> >+ <fieldset class="action"> >+ <button type="button" id="testpatternbutton" class="btn btn-default btn-sm"><i class="fa fa-play"></i> Test prediction pattern</button> >+ </fieldset> >+ </fieldset> >+ >+ [% IF additional_fields %] >+ <div id="subscription_additional_fields"> >+ [% INCLUDE 'additional-fields-entry.inc' available=additional_fields values=additional_field_values %] >+ </div> >+ [% END %] > > [% IF additional_fields %] > <div id="subscription_additional_fields"> [% INCLUDE 'additional-fields-entry.inc' available=additional_fields values=additional_field_values %] </div> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-numberpatterns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-numberpatterns.tt >index 64217e7a9a..8a3808616b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-numberpatterns.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-numberpatterns.tt >@@ -192,65 +192,66 @@ > > <form method="get"> > <fieldset class="rows"> >- <legend>Test prediction pattern</legend> >- <ol> >- <li> >- <label for="frequency">Frequency: </label> >- <select id="frequency"> >- [% FOREACH frequency IN frequencies_loop %] >- <option value="[% frequency.id | html %]">[% frequency.description | html %]</option> >- [% END %] >- </select> >- </li> >- <li> >- <label for="firstacquidate">First issue publication date: </label> >- <input type="text" id="firstacquidate" class="flatpickr" size="10" /> >- </li> >- <li> >- <label for="sublength">Subscription length:</label> >- <select id="subtype"> >- <option value="issues">issues</option> >- <option value="weeks">weeks</option> >- <option value="months">months</option> >- </select> >- <input type="text" id="sublength" size="3" /> >- </li> >- <li> >- <label for="locale">Locale: </label> >- <select id="locale" name="locale"> >- <option value=""></option> >- [% FOREACH locale IN locales %] >- <option value="[% locale.language | html %]">[% locale.description | html %]</option> >- [% END %] >- </select> >- <span class="hint">If empty, English is used</span> >- </li> >- </ol> >- <table> >- <thead> >- <tr> >- <th> </th> >- <th>X</th> >- <th>Y</th> >- <th>Z</th> >- </tr> >- </thead> >- <tbody> >- <tr> >- <td>Begins with</td> >- <td><input type="text" id="lastvalue1" name="lastvalue1" value="[% lastvalue1 | html %]" /></td> >- <td><input type="text" id="lastvalue2" name="lastvalue2" value="[% lastvalue2 | html %]" /></td> >- <td><input type="text" id="lastvalue3" name="lastvalue3" value="[% lastvalue3 | html %]" /></td> >- </tr> >- <tr> >- <td>Inner counter</td> >- <td><input type="text" id="innerloop1" name="innerloop1" value="[% innerloop1 | html %]" /></td> >- <td><input type="text" id="innerloop2" name="innerloop2" value="[% innerloop2 | html %]" /></td> >- <td><input type="text" id="innerloop3" name="innerloop3" value="[% innerloop3 | html %]" /></td> >- </tr> >- </tbody> >- </table> >- <div id="predictionpattern"></div> >+ <legend>Test prediction pattern</legend> >+ <ol> >+ <li> >+ <label for="frequency">Frequency: </label> >+ <select id="frequency"> >+ [% FOREACH frequency IN frequencies_loop %] >+ <option value="[% frequency.id | html %]">[% frequency.description | html %]</option> >+ [% END %] >+ </select> >+ </li> >+ <li> >+ <label for="firstacquidate">First issue publication date: </label> >+ <input type="text" id="firstacquidate" class="flatpickr" size="10" /> >+ </li> >+ <li> >+ <label for="sublength">Subscription length:</label> >+ <select id="subtype"> >+ <option value="issues">issues</option> >+ <option value="weeks">weeks</option> >+ <option value="months">months</option> >+ </select> >+ <input type="text" id="sublength" size="3" /> >+ </li> >+ <li> >+ <label for="locale">Locale: </label> >+ <select id="locale" name="locale"> >+ <option value=""></option> >+ [% FOREACH locale IN locales %] >+ <option value="[% locale.language | html %]" data-subtag="[% locale.subtag | html %]">[% locale.description | html %]</option> >+ [% END %] >+ </select> >+ <span class="hint">If empty, English is used</span> >+ <input type="hidden" id="subtag" name="subtag" value=""> >+ </li> >+ </ol> >+ <table> >+ <thead> >+ <tr> >+ <th> </th> >+ <th>X</th> >+ <th>Y</th> >+ <th>Z</th> >+ </tr> >+ </thead> >+ <tbody> >+ <tr> >+ <td>Begins with</td> >+ <td><input type="text" id="lastvalue1" name="lastvalue1" value="[% lastvalue1 | html %]" /></td> >+ <td><input type="text" id="lastvalue2" name="lastvalue2" value="[% lastvalue2 | html %]" /></td> >+ <td><input type="text" id="lastvalue3" name="lastvalue3" value="[% lastvalue3 | html %]" /></td> >+ </tr> >+ <tr> >+ <td>Inner counter</td> >+ <td><input type="text" id="innerloop1" name="innerloop1" value="[% innerloop1 | html %]" /></td> >+ <td><input type="text" id="innerloop2" name="innerloop2" value="[% innerloop2 | html %]" /></td> >+ <td><input type="text" id="innerloop3" name="innerloop3" value="[% innerloop3 | html %]" /></td> >+ </tr> >+ </tbody> >+ </table> >+ <div id="predictionpattern"></div> > </fieldset> > <fieldset class="action"> > <button type="button" id="test_pattern" class="btn btn-default">Test pattern</button> >@@ -331,6 +332,10 @@ > [% INCLUDE 'calendar.inc' %] > [% INCLUDE 'datatables.inc' %] > <script> >+ function setSubtag () { >+ $("#subtag").val($("#locale").find(':selected').data('subtag')); >+ } >+ > function confirmDelete() { > return confirm(_("Are you sure you want to delete this numbering pattern?")); > } >@@ -364,7 +369,7 @@ > 'lastvalue1', 'lastvalue2', 'lastvalue3', 'add1', 'add2', 'add3', > 'every1', 'every2', 'every3', 'innerloop1', 'innerloop2', 'innerloop3', > 'setto1', 'setto2', 'setto3', 'numbering1', 'numbering2', 'numbering3', >- 'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale' >+ 'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale', 'subtag' > ]; > for(i in ajaxParams) { > var param = ajaxParams[i]; >@@ -405,6 +410,11 @@ > $("#test_pattern").on("click",function(){ > testPattern(); > }); >+ $("#locale").on("change", function() { >+ setSubtag(); >+ }); >+ >+ setSubtag(); > }); > </script> > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js b/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js >index 76aded3f56..89835f5ae0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js >@@ -384,37 +384,12 @@ function testPredictionPattern() { > } > > var ajaxParams = [ >- "to", >- "subtype", >- "sublength", >- "frequency", >- "numberingmethod", >- "lastvalue1", >- "lastvalue2", >- "lastvalue3", >- "add1", >- "add2", >- "add3", >- "every1", >- "every2", >- "every3", >- "innerloop1", >- "innerloop2", >- "innerloop3", >- "setto1", >- "setto2", >- "setto3", >- "numbering1", >- "numbering2", >- "numbering3", >- "whenmorethan1", >- "whenmorethan2", >- "whenmorethan3", >- "locale", >- "sfdescription", >- "unitsperissue", >- "issuesperunit", >- "unit", >+ 'to', 'subtype', 'sublength', 'frequency', 'numberingmethod', >+ 'lastvalue1', 'lastvalue2', 'lastvalue3', 'add1', 'add2', 'add3', >+ 'every1', 'every2', 'every3', 'innerloop1', 'innerloop2', 'innerloop3', >+ 'setto1', 'setto2', 'setto3', 'numbering1', 'numbering2', 'numbering3', >+ 'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale', 'subtag', >+ 'sfdescription', 'unitsperissue', 'issuesperunit', 'unit' > ]; > for (i in ajaxParams) { > var param = ajaxParams[i]; >@@ -688,7 +663,11 @@ function mana_comment_close() { > $("#new_mana_comment").hide(); > } > >-function showPredictionPatternTest(data) { >+function setSubtag () { >+ $("#subtag").val($("#locale").find(':selected').data('subtag')); >+} >+ >+function showPredictionPatternTest( data ){ > $("#displayexample").html(data).show(); > $("#page_2 > div").attr("class", "col-sm-6"); > } >@@ -891,4 +870,10 @@ $(document).ready(function () { > const display = $(this).val() == "1" ? "flex" : "none"; > $(".use_items").css("display", display).find("select").val(""); > }); >+ >+ $("#locale").on("change", function() { >+ setSubtag(); >+ }); >+ >+ setSubtag(); > }); >diff --git a/serials/showpredictionpattern.pl b/serials/showpredictionpattern.pl >index 19d414ccba..fd82f22dcd 100755 >--- a/serials/showpredictionpattern.pl >+++ b/serials/showpredictionpattern.pl >@@ -30,11 +30,12 @@ publication date, based on frequency and first publication date. > > use Modern::Perl; > >-use CGI qw ( -utf8 ); >-use Date::Calc qw( Add_Delta_Days Add_Delta_YM Day_of_Week Delta_Days ); >-use C4::Auth qw( get_template_and_user ); >-use C4::Output qw( output_html_with_http_headers ); >-use C4::Serials qw( GetSubscription GetFictiveIssueNumber GetSeq GetSubscriptionIrregularities GetNextDate GetNextSeq ); >+use CGI qw ( -utf8 ); >+use Date::Calc qw( Add_Delta_Days Add_Delta_YM Day_of_Week Delta_Days ); >+use C4::Auth qw( get_template_and_user ); >+use C4::Output qw( output_html_with_http_headers ); >+use C4::Serials >+ qw( GetSubscription GetFictiveIssueNumber GetSeq GetSubscriptionIrregularities GetNextDate GetNextSeq GetSeasonsTranslations ); > use C4::Serials::Frequency; > use Koha::DateUtils qw( dt_from_string ); > >@@ -97,6 +98,14 @@ $enddate = dt_from_string($enddate)->ymd if $enddate; > $nextacquidate = $nextacquidate ? dt_from_string($nextacquidate)->ymd : $firstacquidate; > my $date = $nextacquidate; > >+my $need_seasons = grep { $_ =~ /^season$/ } %pattern; >+my $need_seasonsabrv = grep { $_ =~ /^seasonabrv$/ } %pattern; >+my $subtag = scalar $input->param('subtag'); >+ >+my $translations; >+$translations = GetSeasonsTranslations( $need_seasons, $need_seasonsabrv, $subtag ) >+ if ( $need_seasons || $need_seasonsabrv ); >+ > my %subscription = ( > locale => scalar $input->param('locale') // '', > lastvalue1 => scalar $input->param('lastvalue1') // '', >@@ -108,6 +117,7 @@ my %subscription = ( > irregularity => '', > countissuesperunit => 1, > firstacquidate => $firstacquidate, >+ translations => $translations, > ); > > my $issuenumber; >@@ -189,6 +199,7 @@ while ( $i < 1000 ) { > > $template->param( > predictions_loop => \@predictions_loop, >+ error_messages => \@{ $translations->{error_messages} }, > ); > > if ( $frequency->{unit} and not $custompattern ) { >diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl >index 8dff969978..61340f2d41 100755 >--- a/serials/subscription-add.pl >+++ b/serials/subscription-add.pl >@@ -231,6 +231,7 @@ if ( $op eq 'cud-addsubscription' ) { > map { > { > language => $_->{iso639_2_code}, >+ subtag => $_->{subtag}, > description => $_->{language_description} || $_->{language} > } > } @{ C4::Languages::getAllLanguages() } >diff --git a/serials/subscription-numberpatterns.pl b/serials/subscription-numberpatterns.pl >index 9211240650..f7c9cae93e 100755 >--- a/serials/subscription-numberpatterns.pl >+++ b/serials/subscription-numberpatterns.pl >@@ -119,6 +119,7 @@ if ( $op && ( $op eq 'new' || $op eq 'modify' ) ) { > map { > { > language => $_->{iso639_2_code}, >+ subtag => $_->{subtag}, > description => $_->{language_description} || $_->{language} > } > } @{ C4::Languages::getAllLanguages() } >diff --git a/t/db_dependent/Serials.t b/t/db_dependent/Serials.t >index 9ddc4719dd..3b0de3d444 100755 >--- a/t/db_dependent/Serials.t >+++ b/t/db_dependent/Serials.t >@@ -6,25 +6,27 @@ > use Modern::Perl; > > use C4::Serials >- qw( getroutinglist updateClaim NewSubscription GetSubscription GetSubscriptionHistoryFromSubscriptionId SearchSubscriptions ModSubscription GetExpirationDate GetSerials GetSerialInformation NewIssue AddItem2Serial DelSubscription GetFullSubscription PrepareSerialsData GetSubscriptionsFromBiblionumber ModSubscriptionHistory GetSerials2 GetLatestSerials GetNextSeq GetSeq CountSubscriptionFromBiblionumber ModSerialStatus findSerialsByStatus HasSubscriptionStrictlyExpired HasSubscriptionExpired GetLateOrMissingIssues check_routing addroutingmember GetNextDate ); >+ qw( getroutinglist updateClaim NewSubscription GetSubscription GetSubscriptionHistoryFromSubscriptionId SearchSubscriptions ModSubscription GetExpirationDate GetSerials GetSerialInformation NewIssue AddItem2Serial DelSubscription GetFullSubscription PrepareSerialsData GetSubscriptionsFromBiblionumber ModSubscriptionHistory GetSerials2 GetLatestSerials GetNextSeq GetSeq CountSubscriptionFromBiblionumber ModSerialStatus findSerialsByStatus HasSubscriptionStrictlyExpired HasSubscriptionExpired GetLateOrMissingIssues check_routing addroutingmember GetNextDate GetSeasonsTranslations ); > use C4::Serials::Frequency; > use C4::Serials::Numberpattern; > use C4::Biblio qw( AddBiblio GetMarcFromKohaField ); > use C4::Budgets qw( AddBudgetPeriod AddBudget ); >-use C4::Items qw( AddItemFromMarc ); >+use C4::Context; >+use C4::Items qw( AddItemFromMarc ); >+use Encode qw( encode ); >+use File::Temp; > use Koha::Database; > use Koha::DateUtils qw( dt_from_string output_pref ); > use Koha::Acquisition::Booksellers; > use t::lib::Mocks; > use t::lib::TestBuilder; > use Test::MockModule; >-use Test::NoWarnings; > use Test::More tests => 64; > > BEGIN { > use_ok( > 'C4::Serials', >- qw( updateClaim NewSubscription GetSubscription GetSubscriptionHistoryFromSubscriptionId SearchSubscriptions ModSubscription GetExpirationDate GetSerials GetSerialInformation NewIssue AddItem2Serial DelSubscription GetFullSubscription PrepareSerialsData GetSubscriptionsFromBiblionumber ModSubscriptionHistory GetSerials2 GetLatestSerials GetNextSeq GetSeq CountSubscriptionFromBiblionumber ModSerialStatus findSerialsByStatus HasSubscriptionStrictlyExpired HasSubscriptionExpired GetLateOrMissingIssues check_routing addroutingmember GetNextDate ) >+ qw( updateClaim NewSubscription GetSubscription GetSubscriptionHistoryFromSubscriptionId SearchSubscriptions ModSubscription GetExpirationDate GetSerials GetSerialInformation NewIssue AddItem2Serial DelSubscription GetFullSubscription PrepareSerialsData GetSubscriptionsFromBiblionumber ModSubscriptionHistory GetSerials2 GetLatestSerials GetNextSeq GetSeq CountSubscriptionFromBiblionumber ModSerialStatus findSerialsByStatus HasSubscriptionStrictlyExpired HasSubscriptionExpired GetLateOrMissingIssues check_routing addroutingmember GetNextDate GetSeasonsTranslations ) > ); > } > >@@ -740,7 +742,7 @@ subtest "test numbering pattern with dates in GetSeq GetNextSeq" => sub { > > subtest "_numeration" => sub { > >- plan tests => 6; >+ plan tests => 8; > > my $s = C4::Serials::_numeration( 0, 'monthname', 'cat' ); > is( $s, "gener" ); >@@ -755,4 +757,74 @@ subtest "_numeration" => sub { > like( $s, qr{^ene\.?} ); > $s = C4::Serials::_numeration( 0, 'monthabrv', 'fr' ); > is( $s, "janv." ); >+ >+ my $translations = { >+ seasons => [ 'Spring', 'Summer', 'Fall', 'Winter' ], >+ seasonsabrv => [ 'Spr', 'Sum', 'Fal', 'Win' ], >+ }; >+ >+ $s = C4::Serials::_numeration( 0, 'season', 'en', $translations ); >+ is( $s, "Spring" ); >+ $s = C4::Serials::_numeration( 0, 'seasonabrv', 'en', $translations ); >+ is( $s, "Spr" ); >+}; >+ >+subtest "GetSeasonsTranslations" => sub { >+ >+ plan tests => 8; >+ >+ my @seasons = qw( Printemps Ãté Automne Hiver ); >+ my @seasonsabrv = qw( Pri Ãté Aut Hiv ); >+ >+ my $dir = C4::Context->config('intranetdir') . '/misc/translator/po/'; >+ my $fh = File::Temp->new( DIR => $dir, SUFFIX => '-staff-prog.po' ); >+ my $filename = $fh->filename; >+ >+ my $txt = ' >+#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt:530 >+#, c-format >+msgid "Spring" >+msgstr "Printemps" >+ >+#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt:530 >+#, c-format >+msgid "Summer" >+msgstr "Ãté" >+ >+#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt:530 >+#, c-format >+msgid "Fall" >+msgstr "Automne" >+ >+#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt:530 >+#, c-format >+msgid "Winter" >+msgstr "Hiver" >+ >+#: koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt:208 >+#: koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt:210 >+#, c-format >+msgid "Sum" >+msgstr "Total" >+ >+#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt:248 >+#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/showpredictionpattern.tt:43 >+#, c-format >+msgid "" >+"%s %sSpring%s %s %sSummer%s %s %sFall%s %s %sWinter%s %s %sSpr%s %s %sSum%s " >+"%s %sFal%s %s %sWin%s %s %s %s " >+msgstr "" >+"%s %sPrintemps%s %s %sÃté%s %s %sAutomne%s %s %sHiver%s %s %sPri%s %s %sÃté" >+"%s %s %sAut%s %s %sHiv%s %s %s %s " >+ '; >+ >+ print $fh encode( 'utf-8', $txt ); >+ close($fh); >+ >+ my $translations = GetSeasonsTranslations( 1, 1, $filename =~ s/($dir|-staff-prog.po)//gr ); >+ >+ for my $idx ( 0 .. $#{ $translations->{seasons} } ) { >+ is( $translations->{seasons}->[$idx], $seasons[$idx] ); >+ is( $translations->{seasonsabrv}->[$idx], $seasonsabrv[$idx] ); >+ } > }; >diff --git a/t/db_dependent/Serials/GetNextSeq.t b/t/db_dependent/Serials/GetNextSeq.t >index fb43902217..54217c87f7 100755 >--- a/t/db_dependent/Serials/GetNextSeq.t >+++ b/t/db_dependent/Serials/GetNextSeq.t >@@ -144,6 +144,7 @@ $subscription = { > irregularity => '3;4;6', > countissuesperunit => 1, > locale => 'C', >+ translations => { seasons => [ 'Spring', 'Summer', 'Fall', 'Winter' ] }, > }; > $pattern = { > add1 => 1, add2 => 0, add3 => 0, >-- >2.43.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 35590
:
159981
|
159982
|
160003
|
160004
|
161272
|
169441
|
170119
|
171032
|
176562
|
176563
|
179836
|
179880
|
180666
|
180683
|
180684
|
180980
|
180981