Bugzilla – Attachment 180684 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: Fix issue number with season and remove unnecessary code
Bug-35590-Fix-issue-number-with-season-and-remove-.patch (text/plain), 12.06 KB, created by
Shi Yao Wang
on 2025-04-04 21:21:39 UTC
(
hide
)
Description:
Bug 35590: Fix issue number with season and remove unnecessary code
Filename:
MIME Type:
Creator:
Shi Yao Wang
Created:
2025-04-04 21:21:39 UTC
Size:
12.06 KB
patch
obsolete
>From 2223af1b8d1b1164a60cb5021b1de96d88e9c9ca Mon Sep 17 00:00:00 2001 >From: Shi Yao Wang <shi-yao.wang@inlibro.com> >Date: Fri, 4 Apr 2025 17:16:45 -0400 >Subject: [PATCH] Bug 35590: Fix issue number with season and remove > unnecessary code > >I also removed one of the tests because we can no longer enter arbitrary >string as language code to use as part of translation file name. > >Test plan remains the same >--- > C4/Serials.pm | 12 +++- > .../en/modules/serials/subscription-add.tt | 5 +- > .../serials/subscription-numberpatterns.tt | 14 +---- > .../intranet-tmpl/prog/js/subscription-add.js | 11 ---- > serials/showpredictionpattern.pl | 7 +-- > serials/subscription-add.pl | 1 - > serials/subscription-numberpatterns.pl | 1 - > t/db_dependent/Serials.t | 61 +------------------ > 8 files changed, 18 insertions(+), 94 deletions(-) > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index 33ba818755..c18db22e47 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -37,6 +37,7 @@ use Try::Tiny; > use C4::Auth qw( haspermission ); > use C4::Biblio qw( GetMarcFromKohaField ModBiblio ); > use C4::Context; >+use C4::Languages; > use C4::Log qw( logaction ); # logaction > use C4::Serials::Frequency qw( GetSubscriptionFrequency ); > use C4::Serials::Numberpattern; >@@ -303,6 +304,8 @@ sub GetSubscription { > $subscription->{comments} = $mana_subscription->{data}->{comments}; > } > >+ $subscription->{translations} = GetSeasonsTranslations(1, 1, $subscription->{locale}); >+ > return $subscription; > } > >@@ -2721,11 +2724,14 @@ Provide translations for the seasons and their abbreviations for the specified l > =cut > > sub GetSeasonsTranslations { >- my ( $need_seasons, $need_seasonsabrv, $subtag ) = @_; >+ my ( $need_seasons, $need_seasonsabrv, $locale ) = @_; > my @seasons = qw( Spring Summer Fall Winter ); > my @seasonsabrv = qw( Spr Sum Fal Win ); > my @error_messages = qw(); > >+ $locale ||= 'eng'; >+ my $subtag = C4::Languages::get_rfc4646_from_iso639( $locale ); >+ > my @dirs = ( > C4::Context->config('intranetdir') . '/misc/translator/po', > C4::Context->config('intranetdir') . '/../../misc/translator/po', >@@ -2733,7 +2739,9 @@ sub GetSeasonsTranslations { > > my $dir = first { -d } @dirs; > >- if ($dir) { >+ if (!$subtag) { >+ push( @error_messages, "The locale $locale doesn't exist" ); >+ } elsif ($dir) { > my @po_paths = glob("$dir/$subtag*staff-prog.po"); > if (@po_paths) { > my $po_path = $po_paths[0]; >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 a20a9af71b..1e62a1108e 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 >@@ -394,13 +394,12 @@ > <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> >+ <option value="[% l.language | html %]" selected="selected">[% l.description | html %]</option> > [% ELSE %] >- <option value="[% l.language | html %]" data-subtag="[% l.subtag | html %]">[% l.description | html %]</option> >+ <option value="[% l.language | 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 8c97fe28fc..64217e7a9a 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 >@@ -220,11 +220,10 @@ > <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> >+ <option value="[% locale.language | 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> >@@ -332,10 +331,6 @@ > [% 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?")); > } >@@ -369,7 +364,7 @@ > 'lastvalue1', 'lastvalue2', 'lastvalue3', 'add1', 'add2', 'add3', > 'every1', 'every2', 'every3', 'innerloop1', 'innerloop2', 'innerloop3', > 'setto1', 'setto2', 'setto3', 'numbering1', 'numbering2', 'numbering3', >- 'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale', 'subtag' >+ 'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale' > ]; > for(i in ajaxParams) { > var param = ajaxParams[i]; >@@ -410,11 +405,6 @@ > $("#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 33a6f15d6a..76aded3f56 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js >@@ -411,7 +411,6 @@ function testPredictionPattern() { > "whenmorethan2", > "whenmorethan3", > "locale", >- "subtag", > "sfdescription", > "unitsperissue", > "issuesperunit", >@@ -689,10 +688,6 @@ 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-sm-6"); >@@ -896,10 +891,4 @@ $(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 fbfc6fbb2b..515188c52d 100755 >--- a/serials/showpredictionpattern.pl >+++ b/serials/showpredictionpattern.pl >@@ -99,14 +99,13 @@ my $date = $nextacquidate; > > my $need_seasons = grep { $_ =~ /^season$/ } %pattern; > my $need_seasonsabrv = grep { $_ =~ /^seasonabrv$/ } %pattern; >-my $subtag = scalar $input->param('subtag'); >+my $locale = scalar $input->param('locale') // ''; > >-my $translations; >-$translations = GetSeasonsTranslations( $need_seasons, $need_seasonsabrv, $subtag ) >+my $translations = GetSeasonsTranslations( $need_seasons, $need_seasonsabrv, $locale ) > if ( $need_seasons || $need_seasonsabrv ); > > my %subscription = ( >- locale => scalar $input->param('locale') // '', >+ locale => $locale, > lastvalue1 => scalar $input->param('lastvalue1') // '', > lastvalue2 => scalar $input->param('lastvalue2') // '', > lastvalue3 => scalar $input->param('lastvalue3') // '', >diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl >index 61340f2d41..8dff969978 100755 >--- a/serials/subscription-add.pl >+++ b/serials/subscription-add.pl >@@ -231,7 +231,6 @@ 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 f7c9cae93e..9211240650 100755 >--- a/serials/subscription-numberpatterns.pl >+++ b/serials/subscription-numberpatterns.pl >@@ -119,7 +119,6 @@ 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 6d4963419a..f833e9e616 100755 >--- a/t/db_dependent/Serials.t >+++ b/t/db_dependent/Serials.t >@@ -21,6 +21,7 @@ use Koha::Acquisition::Booksellers; > use t::lib::Mocks; > use t::lib::TestBuilder; > use Test::MockModule; >+use Test::NoWarnings; > use Test::More tests => 64; > > BEGIN { >@@ -768,63 +769,3 @@ subtest "_numeration" => sub { > $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] ); >- } >-}; >-- >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