From b6de822ad666a55ea5ea7ac984dd26941ec89162 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 7 Feb 2022 09:26:12 +0100 Subject: [PATCH] Bug 30035: Fix month name in prediction pattern We are using %B to display the month name but it seems that using the CLDR pattern LLLL would be more appropriated. https://metacpan.org/pod/DateTime#CLDR-Patterns %B - The full month name. LLLL - The wide stand-alone form for the month. For instance in Catalan: https://metacpan.org/pod/DateTime::Locale::ca %B will display "de gener" when LLLL will be "gener" Test plan: Create a new numbering pattern: Home > Serials > Numbering patterns > New numbering pattern Numbering formula: {X} Label: monthname Add: 1 Every: 1 Set back to: 1 When more than: 999 Formatting: Name of month And test it at the bottom of the form Locale: Catalan The number column should contain "gener", not "de gener" Test other locales and confirm that the output is correct (no change expected for English, French and Spanish for instance). Signed-off-by: Katrin Fischer Signed-off-by: Nick Clemens Signed-off-by: Fridolin Somers --- C4/Serials.pm | 2 +- t/db_dependent/Serials.t | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index 72d16590ea..ad772fecac 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -2511,7 +2511,7 @@ sub _numeration { locale => $locale, ); $string = $num_type =~ /^monthname$/ - ? $dt->strftime("%B") + ? $dt->format_cldr( "LLLL" ) : $dt->strftime("%b"); } elsif ( $num_type =~ /^season$/ ) { my @seasons= qw( Spring Summer Fall Winter ); diff --git a/t/db_dependent/Serials.t b/t/db_dependent/Serials.t index 816a8a9714..293905d931 100755 --- a/t/db_dependent/Serials.t +++ b/t/db_dependent/Serials.t @@ -16,7 +16,7 @@ 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 => 49; +use Test::More tests => 50; 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 )); @@ -451,3 +451,22 @@ subtest "NewSubscription|ModSubscription" => sub { is( $serials->count, 1, "Still only one serial" ); is( $serials->next->biblionumber, $biblio_2->biblionumber, 'ModSubscription should have updated serial.biblionumber'); }; + +subtest "_numeration" => sub { + + plan tests => 6; + + my $s = C4::Serials::_numeration(0, 'monthname', 'cat'); + is( $s, "gener" ); + $s = C4::Serials::_numeration(0, 'monthname', 'es'); + is( $s, "enero" ); + $s = C4::Serials::_numeration(0, 'monthname', 'fr'); + is( $s, "janvier" ); + + $s = C4::Serials::_numeration(0, 'monthabrv', 'cat'); + is( $s, "de gen." ); + $s = C4::Serials::_numeration(0, 'monthabrv', 'es'); + is( $s, "ene" ); + $s = C4::Serials::_numeration(0, 'monthabrv', 'fr'); + is( $s, "janv." ); +}; -- 2.39.5