From c9253082bbbe3bc2529188b0e908053d72b77eff 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 Signed-off-by: Kyle M Hall (cherry picked from commit 93c33c527fdbfad0f46bc26a6b3496cba7d02fbb) Signed-off-by: Andrew Fuerste-Henry --- 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 709a24315a..d27f08a171 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -2503,7 +2503,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 981765dad7..d052148bc1 100755 --- a/t/db_dependent/Serials.t +++ b/t/db_dependent/Serials.t @@ -17,7 +17,7 @@ use Koha::DateUtils; 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'); @@ -452,3 +452,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