Bug 18309: Add UNIMARC field 214 and its subfields
[koha.git] / Koha / Template / Plugin / I18N.pm
blob976c13927f0ab4923cdea0e53be253053502b3c3
1 package Koha::Template::Plugin::I18N;
3 # Copyright BibLibre 2015
5 # This file is part of Koha.
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.
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.
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>.
20 use Modern::Perl;
22 use base qw( Template::Plugin );
24 use C4::Context;
25 use Koha::I18N;
27 =head1 NAME
29 Koha::Template::Plugin::I18N - Translate strings in templates
31 =head1 SYNOPSIS
33 Do not use this plugin directly. Add the following directive
35 [% PROCESS 'i18n.inc' %]
37 and use the macros defined here
39 =head1 METHODS
41 =head2 t
43 [% I18N.t("hello") %]
45 =cut
47 sub t {
48 my ($self, $msgid) = @_;
49 return __($msgid);
52 =head2 tx
54 [% I18N.tx("hello {name}", { name = name }) %]
56 =cut
58 sub tx {
59 my ($self, $msgid, $vars) = @_;
60 return __x($msgid, %$vars);
63 =head2 tn
65 [% I18N.tn("item", "items", count) %]
67 =cut
69 sub tn {
70 my ($self, $msgid, $msgid_plural, $count) = @_;
71 return __n($msgid, $msgid_plural, $count);
74 =head2 tnx
76 [% I18N.tnx("{count} item", "{count} items", count, { count = count }) %]
78 =cut
80 sub tnx {
81 my ($self, $msgid, $msgid_plural, $count, $vars) = @_;
82 return __nx($msgid, $msgid_plural, $count, %$vars);
85 =head2 txn
87 Alias of tnx
89 =cut
91 sub txn {
92 my ($self, $msgid, $msgid_plural, $count, $vars) = @_;
93 return __xn($msgid, $msgid_plural, $count, %$vars);
96 =head2 tp
98 [% I18N.tp("context", "hello") %]
100 =cut
102 sub tp {
103 my ($self, $msgctxt, $msgid) = @_;
104 return __p($msgctxt, $msgid);
107 =head2 tpx
109 [% I18N.tpx("context", "hello {name}", { name = name }) %]
111 =cut
113 sub tpx {
114 my ($self, $msgctxt, $msgid, $vars) = @_;
115 return __px($msgctxt, $msgid, %$vars);
118 =head2 tnp
120 [% I18N.tnp("context", "item", "items") %]
122 =cut
124 sub tnp {
125 my ($self, $msgctxt, $msgid, $msgid_plural, $count) = @_;
126 return __np($msgctxt, $msgid, $msgid_plural, $count);
129 =head2 tnpx
131 [% I18N.tnpx("context", "{count} item", "{count} items", { count = count }) %]
133 =cut
135 sub tnpx {
136 my ($self, $msgctxt, $msgid, $msgid_plural, $count, $vars) = @_;
137 return __np($msgctxt, $msgid, $msgid_plural, $count, %$vars);