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

(-)a/Koha/Template/Filters/I18N.pm (-14 / +13 lines)
Lines 10-17 our $STATIC_FILTERS = { Link Here
10
};
10
};
11
11
12
our $DYNAMIC_FILTERS = {
12
our $DYNAMIC_FILTERS = {
13
    tx => \&tx_factory,
13
    tx  => \&tx_factory,
14
    tn => \&tn_factory,
14
    tn  => \&tn_factory,
15
    tnx => \&tnx_factory,
15
    tnx => \&tnx_factory,
16
16
17
    # i18n functions that takes a context argument (tp, tpx, tnp, tnpx)
17
    # i18n functions that takes a context argument (tp, tpx, tnp, tnpx)
Lines 27-48 our $DYNAMIC_FILTERS = { Link Here
27
};
27
};
28
28
29
sub fetch {
29
sub fetch {
30
    my ($self, $name, $args, $context) = @_;
30
    my ( $self, $name, $args, $context ) = @_;
31
31
32
    return $STATIC_FILTERS->{$name} if $STATIC_FILTERS->{$name};
32
    return $STATIC_FILTERS->{$name} if $STATIC_FILTERS->{$name};
33
33
34
    if (my $factory = $DYNAMIC_FILTERS->{$name}) {
34
    if ( my $factory = $DYNAMIC_FILTERS->{$name} ) {
35
        return $factory->($context, $args ? @$args : ());
35
        return $factory->( $context, $args ? @$args : () );
36
    }
36
    }
37
37
38
    return (undef, Template::Constants::STATUS_DECLINED);
38
    return ( undef, Template::Constants::STATUS_DECLINED );
39
}
39
}
40
40
41
# This sub is never called in theory as Template::Filters::store is called
41
# This sub is never called in theory as Template::Filters::store is called
42
# first and accept all filters.
42
# first and accept all filters.
43
# We declare it anyway, just in case the order of filter providers is changed
43
# We declare it anyway, just in case the order of filter providers is changed
44
sub store {
44
sub store {
45
    return (undef, Template::Constants::STATUS_DECLINED);
45
    return ( undef, Template::Constants::STATUS_DECLINED );
46
}
46
}
47
47
48
sub t {
48
sub t {
Lines 52-83 sub t { Link Here
52
}
52
}
53
53
54
sub tx_factory {
54
sub tx_factory {
55
    my ($context, $vars) = @_;
55
    my ( $context, $vars ) = @_;
56
56
57
    return sub {
57
    return sub {
58
        my ($msgid) = @_;
58
        my ($msgid) = @_;
59
59
60
        return __x($msgid, $vars ? %$vars : ());
60
        return __x( $msgid, $vars ? %$vars : () );
61
    }
61
    }
62
}
62
}
63
63
64
sub tn_factory {
64
sub tn_factory {
65
    my ($context, $msgid_plural, $count) = @_;
65
    my ( $context, $msgid_plural, $count ) = @_;
66
66
67
    return sub {
67
    return sub {
68
        my ($msgid) = @_;
68
        my ($msgid) = @_;
69
69
70
        return __n($msgid, $msgid_plural, $count);
70
        return __n( $msgid, $msgid_plural, $count );
71
    }
71
    }
72
}
72
}
73
73
74
sub tnx_factory {
74
sub tnx_factory {
75
    my ($context, $msgid_plural, $count, $vars) = @_;
75
    my ( $context, $msgid_plural, $count, $vars ) = @_;
76
76
77
    return sub {
77
    return sub {
78
        my ($msgid) = @_;
78
        my ($msgid) = @_;
79
79
80
        return __nx($msgid, $msgid_plural, $count, $vars ? %$vars : ());
80
        return __nx( $msgid, $msgid_plural, $count, $vars ? %$vars : () );
81
    }
81
    }
82
}
82
}
83
83
84
- 

Return to bug 36357