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 <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2022-02-07 09:26:12 +01:00 committed by Kyle Hall
parent 74382c321c
commit 93c33c527f
2 changed files with 21 additions and 2 deletions

View File

@ -2510,7 +2510,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 );

View File

@ -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." );
};