Bug 22847: Correctly displayed circ rule values for max_holds and maxissue*
[koha.git] / Koha / Template / Plugin / I18N.pm
1 package Koha::Template::Plugin::I18N;
2
3 # Copyright BibLibre 2015
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20 use Modern::Perl;
21
22 use base qw( Template::Plugin );
23
24 use C4::Context;
25 use Koha::I18N;
26
27 =head1 NAME
28
29 Koha::Template::Plugin::I18N - Translate strings in templates
30
31 =head1 SYNOPSIS
32
33 Do not use this plugin directly. Add the following directive
34
35     [% PROCESS 'i18n.inc' %]
36
37 and use the macros defined here
38
39 =head1 METHODS
40
41 =head2 t
42
43     [% I18N.t("hello") %]
44
45 =cut
46
47 sub t {
48     my ($self, $msgid) = @_;
49     return __($msgid);
50 }
51
52 =head2 tx
53
54     [% I18N.tx("hello {name}", { name = name }) %]
55
56 =cut
57
58 sub tx {
59     my ($self, $msgid, $vars) = @_;
60     return __x($msgid, %$vars);
61 }
62
63 =head2 tn
64
65     [% I18N.tn("item", "items", count) %]
66
67 =cut
68
69 sub tn {
70     my ($self, $msgid, $msgid_plural, $count) = @_;
71     return __n($msgid, $msgid_plural, $count);
72 }
73
74 =head2 tnx
75
76     [% I18N.tnx("{count} item", "{count} items", count, { count = count }) %]
77
78 =cut
79
80 sub tnx {
81     my ($self, $msgid, $msgid_plural, $count, $vars) = @_;
82     return __nx($msgid, $msgid_plural, $count, %$vars);
83 }
84
85 =head2 txn
86
87 Alias of tnx
88
89 =cut
90
91 sub txn {
92     my ($self, $msgid, $msgid_plural, $count, $vars) = @_;
93     return __xn($msgid, $msgid_plural, $count, %$vars);
94 }
95
96 =head2 tp
97
98     [% I18N.tp("context", "hello") %]
99
100 =cut
101
102 sub tp {
103     my ($self, $msgctxt, $msgid) = @_;
104     return __p($msgctxt, $msgid);
105 }
106
107 =head2 tpx
108
109     [% I18N.tpx("context", "hello {name}", { name = name }) %]
110
111 =cut
112
113 sub tpx {
114     my ($self, $msgctxt, $msgid, $vars) = @_;
115     return __px($msgctxt, $msgid, %$vars);
116 }
117
118 =head2 tnp
119
120     [% I18N.tnp("context", "item", "items") %]
121
122 =cut
123
124 sub tnp {
125     my ($self, $msgctxt, $msgid, $msgid_plural, $count) = @_;
126     return __np($msgctxt, $msgid, $msgid_plural, $count);
127 }
128
129 =head2 tnpx
130
131     [% I18N.tnpx("context", "{count} item", "{count} items", { count = count }) %]
132
133 =cut
134
135 sub tnpx {
136     my ($self, $msgctxt, $msgid, $msgid_plural, $count, $vars) = @_;
137     return __np($msgctxt, $msgid, $msgid_plural, $count, %$vars);
138 }
139
140 1;