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>.
22 use base qw( Template::Plugin );
29 Koha::Template::Plugin::I18N - Translate strings in templates
33 Do not use this plugin directly. Add the following directive
35 [% PROCESS 'i18n.inc' %]
37 and use the macros defined here
48 my ($self, $msgid) = @_;
54 [% I18N.tx("hello {name}", { name = name }) %]
59 my ($self, $msgid, $vars) = @_;
60 return __x($msgid, %$vars);
65 [% I18N.tn("item", "items", count) %]
70 my ($self, $msgid, $msgid_plural, $count) = @_;
71 return __n($msgid, $msgid_plural, $count);
76 [% I18N.tnx("{count} item", "{count} items", count, { count = count }) %]
81 my ($self, $msgid, $msgid_plural, $count, $vars) = @_;
82 return __nx($msgid, $msgid_plural, $count, %$vars);
92 my ($self, $msgid, $msgid_plural, $count, $vars) = @_;
93 return __xn($msgid, $msgid_plural, $count, %$vars);
98 [% I18N.tp("context", "hello") %]
103 my ($self, $msgctxt, $msgid) = @_;
104 return __p($msgctxt, $msgid);
109 [% I18N.tpx("context", "hello {name}", { name = name }) %]
114 my ($self, $msgctxt, $msgid, $vars) = @_;
115 return __px($msgctxt, $msgid, %$vars);
120 [% I18N.tnp("context", "item", "items") %]
125 my ($self, $msgctxt, $msgid, $msgid_plural, $count) = @_;
126 return __np($msgctxt, $msgid, $msgid_plural, $count);
131 [% I18N.tnpx("context", "{count} item", "{count} items", { count = count }) %]
136 my ($self, $msgctxt, $msgid, $msgid_plural, $count, $vars) = @_;
137 return __np($msgctxt, $msgid, $msgid_plural, $count, %$vars);