Bugzilla – Attachment 159982 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), 31.42 KB, created by
Emily-Rose Francoeur
on 2023-12-18 19:28:58 UTC
(
hide
)
Description:
Bug 35590: Translate the seasons when testing the numbering pattern with a selected locale
Filename:
MIME Type:
Creator:
Emily-Rose Francoeur
Created:
2023-12-18 19:28:58 UTC
Size:
31.42 KB
patch
obsolete
>From 894e7625d39b8ad48943ac42e96d32e261daa440 Mon Sep 17 00:00:00 2001 >From: Emily-Rose Francoeur <emily-rose.francoeur@inlibro.com> >Date: Mon, 18 Dec 2023 19:15:45 +0000 >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 | 186 ++++++++++++++---- > .../modules/serials/showpredictionpattern.tt | 9 + > .../en/modules/serials/subscription-add.tt | 5 +- > .../serials/subscription-numberpatterns.tt | 14 +- > .../intranet-tmpl/prog/js/subscription-add.js | 11 +- > serials/showpredictionpattern.pl | 31 +-- > serials/subscription-add.pl | 15 +- > serials/subscription-numberpatterns.pl | 15 +- > t/db_dependent/Serials.t | 86 +++++++- > t/db_dependent/Serials/GetNextSeq.t | 15 +- > 10 files changed, 304 insertions(+), 83 deletions(-) > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index ec88b0f3e6..409a2969e9 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -48,6 +48,8 @@ use Koha::Subscription::Histories; > use Koha::Subscriptions; > use Koha::Suggestions; > use Koha::TemplateUtils qw( process_tt ); >+use List::Util qw( first ); >+use Locale::PO; > > # Define statuses > use constant { >@@ -76,35 +78,36 @@ BEGIN { > require Exporter; > @ISA = qw(Exporter); > @EXPORT_OK = qw( >- NewSubscription ModSubscription DelSubscription >- GetSubscription CountSubscriptionFromBiblionumber GetSubscriptionsFromBiblionumber >- SearchSubscriptions >- GetFullSubscriptionsFromBiblionumber GetFullSubscription ModSubscriptionHistory >- HasSubscriptionStrictlyExpired HasSubscriptionExpired GetExpirationDate abouttoexpire >- GetFictiveIssueNumber >- GetSubscriptionHistoryFromSubscriptionId >- >- GetNextSeq GetSeq NewIssue GetSerials >- GetLatestSerials ModSerialStatus GetNextDate >- CloseSubscription ReopenSubscription >- subscriptionCurrentlyOnOrder >- can_claim_subscription can_edit_subscription can_show_subscription >- GetSerials2 >- GetSubscriptionLength ReNewSubscription GetLateOrMissingIssues >- GetSerialInformation AddItem2Serial >- PrepareSerialsData GetNextExpected ModNextExpected >- GetSubscriptionIrregularities >- GetPreviousSerialid >- >- GetSuppliersWithLateIssues >- getroutinglist delroutingmember addroutingmember >- reorder_members >- check_routing updateClaim >- CountIssues >- HasItems >- >- findSerialsByStatus >- >+ NewSubscription ModSubscription DelSubscription >+ GetSubscription CountSubscriptionFromBiblionumber GetSubscriptionsFromBiblionumber >+ SearchSubscriptions >+ GetFullSubscriptionsFromBiblionumber GetFullSubscription ModSubscriptionHistory >+ HasSubscriptionStrictlyExpired HasSubscriptionExpired GetExpirationDate abouttoexpire >+ GetFictiveIssueNumber >+ GetSubscriptionHistoryFromSubscriptionId >+ >+ GetNextSeq GetSeq NewIssue GetSerials >+ GetLatestSerials ModSerialStatus GetNextDate >+ CloseSubscription ReopenSubscription >+ subscriptionCurrentlyOnOrder >+ can_claim_subscription can_edit_subscription can_show_subscription >+ GetSerials2 >+ GetSubscriptionLength ReNewSubscription GetLateOrMissingIssues >+ GetSerialInformation AddItem2Serial >+ PrepareSerialsData GetNextExpected ModNextExpected >+ GetSubscriptionIrregularities >+ GetPreviousSerialid >+ >+ GetSuppliersWithLateIssues >+ getroutinglist delroutingmember addroutingmember >+ reorder_members >+ check_routing updateClaim >+ CountIssues >+ HasItems >+ >+ findSerialsByStatus >+ >+ GetSeasonsTranslations > ); > } > >@@ -851,7 +854,7 @@ sub GetNextSeq { > my $numberingmethod = $pattern->{numberingmethod}; > my $calculated = ""; > if ($numberingmethod) { >- $calculated = $numberingmethod; >+ $calculated = $numberingmethod; > my $locale = $subscription->{locale}; > $newlastvalue1 = $subscription->{lastvalue1} || 0; > $newlastvalue2 = $subscription->{lastvalue2} || 0; >@@ -859,7 +862,10 @@ 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/) { > $calc{$_} = 1 if ($numberingmethod =~ /\{$_\}/); > } >@@ -897,15 +903,15 @@ sub GetNextSeq { > } > } > if($calc{'X'}) { >- my $newlastvalue1string = _numeration( $newlastvalue1, $pattern->{numbering1}, $locale ); >+ my $newlastvalue1string = _numeration( $newlastvalue1, $pattern->{numbering1}, $locale, $translations ); > $calculated =~ s/\{X\}/$newlastvalue1string/g; > } > if($calc{'Y'}) { >- my $newlastvalue2string = _numeration( $newlastvalue2, $pattern->{numbering2}, $locale ); >+ my $newlastvalue2string = _numeration( $newlastvalue2, $pattern->{numbering2}, $locale, $translations ); > $calculated =~ s/\{Y\}/$newlastvalue2string/g; > } > if($calc{'Z'}) { >- my $newlastvalue3string = _numeration( $newlastvalue3, $pattern->{numbering3}, $locale ); >+ my $newlastvalue3string = _numeration( $newlastvalue3, $pattern->{numbering3}, $locale, $translations ); > $calculated =~ s/\{Z\}/$newlastvalue3string/g; > } > >@@ -934,18 +940,21 @@ 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; > return $calculated; > } >@@ -2501,7 +2510,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'; >@@ -2529,13 +2538,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; > } >@@ -2597,6 +2604,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 ); >@@ -2691,6 +2750,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 ea6e6ab46d..bd20729690 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/showpredictionpattern.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/showpredictionpattern.tt >@@ -84,6 +84,15 @@ > </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> >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 19d53a1c33..45d416f4f6 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 >@@ -383,12 +383,13 @@ fieldset.rows table { clear: none; margin: 0; } > <option value=""></option> > [% FOREACH l IN locales %] > [% IF l.language == locale %] >- <option value="[% l.language | html %]" selected="selected">[% l.description | html %]</option> >+ <option value="[% l.language | html %]" data-subtag="[% l.subtag | html %]" selected="selected">[% l.description | html %]</option> > [% ELSE %] >- <option value="[% l.language | html %]">[% l.description | html %]</option> >+ <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"> >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 6bc37ca6f0..0821d07155 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 >@@ -206,10 +206,11 @@ > <select id="locale" name="locale"> > <option value=""></option> > [% FOREACH locale IN locales %] >- <option value="[% locale.language | html %]">[% locale.description | html %]</option> >+ <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> >@@ -324,6 +325,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?")); > } >@@ -357,7 +362,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]; >@@ -400,6 +405,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 ebf0977d47..86eff69e4b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js >@@ -329,7 +329,7 @@ function testPredictionPattern() { > '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', > 'sfdescription', 'unitsperissue', 'issuesperunit', 'unit' > ]; > for(i in ajaxParams) { >@@ -543,6 +543,10 @@ function mana_comment_close(){ > $("#new_mana_comment").hide(); > } > >+function setSubtag () { >+ $("#subtag").val($("#locale").find(':selected').data('subtag')); >+} >+ > function showPredictionPatternTest( data ){ > $("#displayexample").html(data).show(); > $("#page_2 > div").attr("class","col-xs-6"); >@@ -744,4 +748,9 @@ $(document).ready(function() { > $(".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 9fc801102b..9b1d4f76ea 100755 >--- a/serials/showpredictionpattern.pl >+++ b/serials/showpredictionpattern.pl >@@ -34,7 +34,7 @@ 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 C4::Serials qw( GetSubscription GetFictiveIssueNumber GetSeq GetSubscriptionIrregularities GetNextDate GetNextSeq GetSeasonsTranslations ); > use C4::Serials::Frequency; > use Koha::DateUtils qw( dt_from_string ); > >@@ -97,17 +97,25 @@ $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') // '', >- lastvalue2 => scalar $input->param('lastvalue2') // '', >- lastvalue3 => scalar $input->param('lastvalue3') // '', >- innerloop1 => scalar $input->param('innerloop1') // '', >- innerloop2 => scalar $input->param('innerloop2') // '', >- innerloop3 => scalar $input->param('innerloop3') // '', >- irregularity => '', >- countissuesperunit => 1, >- firstacquidate => $firstacquidate, >+ locale => scalar $input->param('locale') // '', >+ lastvalue1 => scalar $input->param('lastvalue1') // '', >+ lastvalue2 => scalar $input->param('lastvalue2') // '', >+ lastvalue3 => scalar $input->param('lastvalue3') // '', >+ innerloop1 => scalar $input->param('innerloop1') // '', >+ innerloop2 => scalar $input->param('innerloop2') // '', >+ innerloop3 => scalar $input->param('innerloop3') // '', >+ irregularity => '', >+ countissuesperunit => 1, >+ firstacquidate => $firstacquidate, >+ translations => $translations, > ); > > my $issuenumber; >@@ -178,6 +186,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 f8cbc572f2..7fae03ee8a 100755 >--- a/serials/subscription-add.pl >+++ b/serials/subscription-add.pl >@@ -222,12 +222,15 @@ if ($op eq 'addsubscription') { > } > $template->param(numberpatterns => \@numberpatternloop); > >- my $languages = [ map { >- { >- language => $_->{iso639_2_code}, >- description => $_->{language_description} || $_->{language} >- } >- } @{ C4::Languages::getAllLanguages() } ]; >+ my $languages = [ >+ map { >+ { >+ language => $_->{iso639_2_code}, >+ subtag => $_->{subtag}, >+ description => $_->{language_description} || $_->{language} >+ } >+ } @{ C4::Languages::getAllLanguages() } >+ ]; > > $template->param( locales => $languages ); > >diff --git a/serials/subscription-numberpatterns.pl b/serials/subscription-numberpatterns.pl >index a9bc998835..6bb05469a4 100755 >--- a/serials/subscription-numberpatterns.pl >+++ b/serials/subscription-numberpatterns.pl >@@ -110,12 +110,15 @@ if($op && ($op eq 'new' || $op eq 'modify')) { > } > } > my @frequencies = GetSubscriptionFrequencies(); >- my $languages = [ map { >- { >- language => $_->{iso639_2_code}, >- description => $_->{language_description} || $_->{language} >- } >- } @{ C4::Languages::getAllLanguages() } ]; >+ my $languages = [ >+ map { >+ { >+ language => $_->{iso639_2_code}, >+ subtag => $_->{subtag}, >+ description => $_->{language_description} || $_->{language} >+ } >+ } @{ C4::Languages::getAllLanguages() } >+ ]; > > $template->param( > $op => 1, >diff --git a/t/db_dependent/Serials.t b/t/db_dependent/Serials.t >index 65c563d164..faa349c6c8 100755 >--- a/t/db_dependent/Serials.t >+++ b/t/db_dependent/Serials.t >@@ -4,22 +4,28 @@ > # Add more tests here!!! > > use Modern::Perl; >- >-use 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 ); >+use 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 GetSeasonsTranslations ); > use C4::Serials::Frequency; > use C4::Serials::Numberpattern; > use C4::Biblio qw( AddBiblio GetMarcFromKohaField ); > use C4::Budgets qw( AddBudgetPeriod AddBudget ); >+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::More tests => 54; >+use Test::More tests => 55; > > 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 )); >+ 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 GetSeasonsTranslations ) >+ ); > } > > my $schema = Koha::Database->new->schema; >@@ -549,7 +555,7 @@ subtest "NewSubscription|ModSubscription" => sub { > > subtest "_numeration" => sub { > >- plan tests => 6; >+ plan tests => 8; > > my $s = C4::Serials::_numeration(0, 'monthname', 'cat'); > is( $s, "gener" ); >@@ -564,4 +570,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 270568de60..1f40812f4c 100755 >--- a/t/db_dependent/Serials/GetNextSeq.t >+++ b/t/db_dependent/Serials/GetNextSeq.t >@@ -135,14 +135,15 @@ is($seq, 'X: May'); > > # TEST CASE 4 - 1 variable, use 'season' numbering, from 0 to 3 > $subscription = { >- periodicity => $id, >- firstacquidate => '1970-01-01', >- lastvalue1 => 0, lastvalue2 => 1, lastvalue3 => 1, >- innerloop1 => 0, innerloop2 => 0, innerloop3 => 0, >- skip_serialseq => 1, >- irregularity => '3;4;6', >+ periodicity => $id, >+ firstacquidate => '1970-01-01', >+ lastvalue1 => 0, lastvalue2 => 1, lastvalue3 => 1, >+ innerloop1 => 0, innerloop2 => 0, innerloop3 => 0, >+ skip_serialseq => 1, >+ irregularity => '3;4;6', > countissuesperunit => 1, >- locale => 'C', >+ locale => 'C', >+ translations => { seasons => [ 'Spring', 'Summer', 'Fall', 'Winter' ] }, > }; > $pattern = { > add1 => 1, add2 => 0, add3 => 0, >-- >2.34.1
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