View | Details | Raw Unified | Return to bug 35590
Collapse All | Expand All

(-)a/C4/Serials.pm (-2 / +10 lines)
Lines 37-42 use Try::Tiny; Link Here
37
use C4::Auth   qw( haspermission );
37
use C4::Auth   qw( haspermission );
38
use C4::Biblio qw( GetMarcFromKohaField ModBiblio );
38
use C4::Biblio qw( GetMarcFromKohaField ModBiblio );
39
use C4::Context;
39
use C4::Context;
40
use C4::Languages;
40
use C4::Log                qw( logaction );                  # logaction
41
use C4::Log                qw( logaction );                  # logaction
41
use C4::Serials::Frequency qw( GetSubscriptionFrequency );
42
use C4::Serials::Frequency qw( GetSubscriptionFrequency );
42
use C4::Serials::Numberpattern;
43
use C4::Serials::Numberpattern;
Lines 303-308 sub GetSubscription { Link Here
303
        $subscription->{comments} = $mana_subscription->{data}->{comments};
304
        $subscription->{comments} = $mana_subscription->{data}->{comments};
304
    }
305
    }
305
306
307
    $subscription->{translations} = GetSeasonsTranslations(1, 1, $subscription->{locale});
308
306
    return $subscription;
309
    return $subscription;
307
}
310
}
308
311
Lines 2721-2731 Provide translations for the seasons and their abbreviations for the specified l Link Here
2721
=cut
2724
=cut
2722
2725
2723
sub GetSeasonsTranslations {
2726
sub GetSeasonsTranslations {
2724
    my ( $need_seasons, $need_seasonsabrv, $subtag ) = @_;
2727
    my ( $need_seasons, $need_seasonsabrv, $locale ) = @_;
2725
    my @seasons        = qw( Spring Summer Fall Winter );
2728
    my @seasons        = qw( Spring Summer Fall Winter );
2726
    my @seasonsabrv    = qw( Spr Sum Fal Win );
2729
    my @seasonsabrv    = qw( Spr Sum Fal Win );
2727
    my @error_messages = qw();
2730
    my @error_messages = qw();
2728
2731
2732
    $locale ||= 'eng';
2733
    my $subtag = C4::Languages::get_rfc4646_from_iso639( $locale );
2734
2729
    my @dirs = (
2735
    my @dirs = (
2730
        C4::Context->config('intranetdir') . '/misc/translator/po',
2736
        C4::Context->config('intranetdir') . '/misc/translator/po',
2731
        C4::Context->config('intranetdir') . '/../../misc/translator/po',
2737
        C4::Context->config('intranetdir') . '/../../misc/translator/po',
Lines 2733-2739 sub GetSeasonsTranslations { Link Here
2733
2739
2734
    my $dir = first { -d } @dirs;
2740
    my $dir = first { -d } @dirs;
2735
2741
2736
    if ($dir) {
2742
    if (!$subtag) {
2743
        push( @error_messages, "The locale $locale doesn't exist" );
2744
    } elsif ($dir) {
2737
        my @po_paths = glob("$dir/$subtag*staff-prog.po");
2745
        my @po_paths = glob("$dir/$subtag*staff-prog.po");
2738
        if (@po_paths) {
2746
        if (@po_paths) {
2739
            my $po_path     = $po_paths[0];
2747
            my $po_path     = $po_paths[0];
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt (-3 / +2 lines)
Lines 394-406 Link Here
394
                                    <option value=""></option>
394
                                    <option value=""></option>
395
                                    [% FOREACH l IN locales %]
395
                                    [% FOREACH l IN locales %]
396
                                        [% IF l.language == locale %]
396
                                        [% IF l.language == locale %]
397
                                            <option value="[% l.language | html %]" data-subtag="[% l.subtag | html %]" selected="selected">[% l.description | html %]</option>
397
                                            <option value="[% l.language | html %]" selected="selected">[% l.description | html %]</option>
398
                                        [% ELSE %]
398
                                        [% ELSE %]
399
                                            <option value="[% l.language | html %]" data-subtag="[% l.subtag | html %]">[% l.description | html %]</option>
399
                                            <option value="[% l.language | html %]">[% l.description | html %]</option>
400
                                        [% END %]
400
                                        [% END %]
401
                                    [% END %]
401
                                    [% END %]
402
                                </select>
402
                                </select>
403
                                <input type="hidden" id="subtag" name="subtag" value="">
404
                                <div class="hint">If empty, English is used</div>
403
                                <div class="hint">If empty, English is used</div>
405
                            </li>
404
                            </li>
406
                            <li id="more_options">
405
                            <li id="more_options">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-numberpatterns.tt (-12 / +2 lines)
Lines 220-230 Link Here
220
                        <select id="locale" name="locale">
220
                        <select id="locale" name="locale">
221
                            <option value=""></option>
221
                            <option value=""></option>
222
                            [% FOREACH locale IN locales %]
222
                            [% FOREACH locale IN locales %]
223
                                <option value="[% locale.language | html %]" data-subtag="[% locale.subtag | html %]">[% locale.description | html %]</option>
223
                                <option value="[% locale.language | html %]">[% locale.description | html %]</option>
224
                            [% END %]
224
                            [% END %]
225
                        </select>
225
                        </select>
226
                        <span class="hint">If empty, English is used</span>
226
                        <span class="hint">If empty, English is used</span>
227
                        <input type="hidden" id="subtag" name="subtag" value="">
228
                    </li>
227
                    </li>
229
                </ol>
228
                </ol>
230
                <table>
229
                <table>
Lines 332-341 Link Here
332
    [% INCLUDE 'calendar.inc' %]
331
    [% INCLUDE 'calendar.inc' %]
333
    [% INCLUDE 'datatables.inc' %]
332
    [% INCLUDE 'datatables.inc' %]
334
    <script>
333
    <script>
335
        function setSubtag () {
336
            $("#subtag").val($("#locale").find(':selected').data('subtag'));
337
        }
338
339
        function confirmDelete() {
334
        function confirmDelete() {
340
            return confirm(_("Are you sure you want to delete this numbering pattern?"));
335
            return confirm(_("Are you sure you want to delete this numbering pattern?"));
341
        }
336
        }
Lines 369-375 Link Here
369
                    'lastvalue1', 'lastvalue2', 'lastvalue3', 'add1', 'add2', 'add3',
364
                    'lastvalue1', 'lastvalue2', 'lastvalue3', 'add1', 'add2', 'add3',
370
                    'every1', 'every2', 'every3', 'innerloop1', 'innerloop2', 'innerloop3',
365
                    'every1', 'every2', 'every3', 'innerloop1', 'innerloop2', 'innerloop3',
371
                    'setto1', 'setto2', 'setto3', 'numbering1', 'numbering2', 'numbering3',
366
                    'setto1', 'setto2', 'setto3', 'numbering1', 'numbering2', 'numbering3',
372
                    'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale', 'subtag'
367
                    'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale'
373
                ];
368
                ];
374
                for(i in ajaxParams) {
369
                for(i in ajaxParams) {
375
                    var param = ajaxParams[i];
370
                    var param = ajaxParams[i];
Lines 410-420 Link Here
410
            $("#test_pattern").on("click",function(){
405
            $("#test_pattern").on("click",function(){
411
                 testPattern();
406
                 testPattern();
412
            });
407
            });
413
            $("#locale").on("change", function() {
414
                setSubtag();
415
            });
416
417
            setSubtag();
418
        });
408
        });
419
    </script>
409
    </script>
420
[% END %]
410
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js (-11 lines)
Lines 411-417 function testPredictionPattern() { Link Here
411
        "whenmorethan2",
411
        "whenmorethan2",
412
        "whenmorethan3",
412
        "whenmorethan3",
413
        "locale",
413
        "locale",
414
        "subtag",
415
        "sfdescription",
414
        "sfdescription",
416
        "unitsperissue",
415
        "unitsperissue",
417
        "issuesperunit",
416
        "issuesperunit",
Lines 689-698 function mana_comment_close() { Link Here
689
    $("#new_mana_comment").hide();
688
    $("#new_mana_comment").hide();
690
}
689
}
691
690
692
function setSubtag() {
693
    $("#subtag").val($("#locale").find(':selected').data('subtag'));
694
}
695
696
function showPredictionPatternTest(data) {
691
function showPredictionPatternTest(data) {
697
    $("#displayexample").html(data).show();
692
    $("#displayexample").html(data).show();
698
    $("#page_2 > div").attr("class", "col-sm-6");
693
    $("#page_2 > div").attr("class", "col-sm-6");
Lines 896-905 $(document).ready(function () { Link Here
896
        const display = $(this).val() == "1" ? "flex" : "none";
891
        const display = $(this).val() == "1" ? "flex" : "none";
897
        $(".use_items").css("display", display).find("select").val("");
892
        $(".use_items").css("display", display).find("select").val("");
898
    });
893
    });
899
900
    $("#locale").on("change", function() {
901
        setSubtag();
902
    });
903
904
    setSubtag();
905
});
894
});
(-)a/serials/showpredictionpattern.pl (-4 / +3 lines)
Lines 99-112 my $date = $nextacquidate; Link Here
99
99
100
my $need_seasons     = grep { $_ =~ /^season$/ } %pattern;
100
my $need_seasons     = grep { $_ =~ /^season$/ } %pattern;
101
my $need_seasonsabrv = grep { $_ =~ /^seasonabrv$/ } %pattern;
101
my $need_seasonsabrv = grep { $_ =~ /^seasonabrv$/ } %pattern;
102
my $subtag           = scalar $input->param('subtag');
102
my $locale = scalar $input->param('locale') // '';
103
103
104
my $translations;
104
my $translations = GetSeasonsTranslations( $need_seasons, $need_seasonsabrv, $locale )
105
$translations = GetSeasonsTranslations( $need_seasons, $need_seasonsabrv, $subtag )
106
    if ( $need_seasons || $need_seasonsabrv );
105
    if ( $need_seasons || $need_seasonsabrv );
107
106
108
my %subscription = (
107
my %subscription = (
109
    locale             => scalar $input->param('locale')     // '',
108
    locale             => $locale,
110
    lastvalue1         => scalar $input->param('lastvalue1') // '',
109
    lastvalue1         => scalar $input->param('lastvalue1') // '',
111
    lastvalue2         => scalar $input->param('lastvalue2') // '',
110
    lastvalue2         => scalar $input->param('lastvalue2') // '',
112
    lastvalue3         => scalar $input->param('lastvalue3') // '',
111
    lastvalue3         => scalar $input->param('lastvalue3') // '',
(-)a/serials/subscription-add.pl (-1 lines)
Lines 231-237 if ( $op eq 'cud-addsubscription' ) { Link Here
231
        map {
231
        map {
232
            {
232
            {
233
                language    => $_->{iso639_2_code},
233
                language    => $_->{iso639_2_code},
234
                subtag      => $_->{subtag},
235
                description => $_->{language_description} || $_->{language}
234
                description => $_->{language_description} || $_->{language}
236
            }
235
            }
237
        } @{ C4::Languages::getAllLanguages() }
236
        } @{ C4::Languages::getAllLanguages() }
(-)a/serials/subscription-numberpatterns.pl (-1 lines)
Lines 119-125 if ( $op && ( $op eq 'new' || $op eq 'modify' ) ) { Link Here
119
        map {
119
        map {
120
            {
120
            {
121
                language    => $_->{iso639_2_code},
121
                language    => $_->{iso639_2_code},
122
                subtag      => $_->{subtag},
123
                description => $_->{language_description} || $_->{language}
122
                description => $_->{language_description} || $_->{language}
124
            }
123
            }
125
        } @{ C4::Languages::getAllLanguages() }
124
        } @{ C4::Languages::getAllLanguages() }
(-)a/t/db_dependent/Serials.t (-61 / +1 lines)
Lines 21-26 use Koha::Acquisition::Booksellers; Link Here
21
use t::lib::Mocks;
21
use t::lib::Mocks;
22
use t::lib::TestBuilder;
22
use t::lib::TestBuilder;
23
use Test::MockModule;
23
use Test::MockModule;
24
use Test::NoWarnings;
24
use Test::More tests => 64;
25
use Test::More tests => 64;
25
26
26
BEGIN {
27
BEGIN {
Lines 768-830 subtest "_numeration" => sub { Link Here
768
    $s = C4::Serials::_numeration( 0, 'seasonabrv', 'en', $translations );
769
    $s = C4::Serials::_numeration( 0, 'seasonabrv', 'en', $translations );
769
    is( $s, "Spr" );
770
    is( $s, "Spr" );
770
};
771
};
771
772
subtest "GetSeasonsTranslations" => sub {
773
774
    plan tests => 8;
775
776
    my @seasons     = qw( Printemps Été Automne Hiver );
777
    my @seasonsabrv = qw( Pri Été Aut Hiv );
778
779
    my $dir      = C4::Context->config('intranetdir') . '/misc/translator/po/';
780
    my $fh       = File::Temp->new( DIR => $dir, SUFFIX => '-staff-prog.po' );
781
    my $filename = $fh->filename;
782
783
    my $txt = '
784
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt:530
785
#, c-format
786
msgid "Spring"
787
msgstr "Printemps"
788
789
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt:530
790
#, c-format
791
msgid "Summer"
792
msgstr "Été"
793
794
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt:530
795
#, c-format
796
msgid "Fall"
797
msgstr "Automne"
798
799
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt:530
800
#, c-format
801
msgid "Winter"
802
msgstr "Hiver"
803
804
#: koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt:208
805
#: koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt:210
806
#, c-format
807
msgid "Sum"
808
msgstr "Total"
809
810
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt:248
811
#: koha-tmpl/intranet-tmpl/prog/en/modules/serials/showpredictionpattern.tt:43
812
#, c-format
813
msgid ""
814
"%s %sSpring%s %s %sSummer%s %s %sFall%s %s %sWinter%s %s %sSpr%s %s %sSum%s "
815
"%s %sFal%s %s %sWin%s %s %s %s "
816
msgstr ""
817
"%s %sPrintemps%s %s %sÉté%s %s %sAutomne%s %s %sHiver%s %s %sPri%s %s %sÉté"
818
"%s %s %sAut%s %s %sHiv%s %s %s %s "
819
    ';
820
821
    print $fh encode( 'utf-8', $txt );
822
    close($fh);
823
824
    my $translations = GetSeasonsTranslations( 1, 1, $filename =~ s/($dir|-staff-prog.po)//gr );
825
826
    for my $idx ( 0 .. $#{ $translations->{seasons} } ) {
827
        is( $translations->{seasons}->[$idx],     $seasons[$idx] );
828
        is( $translations->{seasonsabrv}->[$idx], $seasonsabrv[$idx] );
829
    }
830
};
831
- 

Return to bug 35590