|
Lines 22-28
use Modern::Perl;
Link Here
|
| 22 |
use base qw( Template::Plugin ); |
22 |
use base qw( Template::Plugin ); |
| 23 |
|
23 |
|
| 24 |
use C4::Context; |
24 |
use C4::Context; |
| 25 |
use Koha::I18N qw( __ __n __np __npx __nx __p __px __x __xn ); |
25 |
use Koha::I18N qw( __ __n __np __npx __nx __p __px __x __xn __d __dn __dp __dnp __dx __dnx __dpx __dnpx); |
| 26 |
|
26 |
|
| 27 |
=head1 NAME |
27 |
=head1 NAME |
| 28 |
|
28 |
|
|
Lines 42-47
Koha::Template::Plugin::I18N - Translate strings in templates
Link Here
|
| 42 |
[% I18N.tnp('bibliographic material', "item", "items", count) %] |
42 |
[% I18N.tnp('bibliographic material', "item", "items", count) %] |
| 43 |
[% I18N.tnpx('bibliographic material', "{count} item", "{count} items", count, { count = count }) %] |
43 |
[% I18N.tnpx('bibliographic material', "{count} item", "{count} items", count, { count = count }) %] |
| 44 |
|
44 |
|
|
|
45 |
[%# For plugins %] |
| 46 |
[% I18N.td("MyPlugin", "Hello!") %] |
| 47 |
[% I18N.tdx("MyPlugin", "Hello {name}", { name = name }) %] |
| 48 |
[% I18N.tdn("MyPlugin", "Hello friend", "Hello friends", count) %] |
| 49 |
[% I18N.tdnx("MyPlugin", "Hello my {count} friend", "Hello my {count} friends", count, { count = count }) %] |
| 50 |
[% I18N.tdp("MyPlugin", 'verb', 'Item') # to order %] |
| 51 |
[% I18N.tdnp("MyPlugin", 'bibliographic material', "item", "items", count) %] |
| 52 |
[% I18N.tdnpx("MyPlugin", 'bibliographic material', "{count} item", "{count} items", count, { count = count }) %] |
| 53 |
|
| 45 |
Do not use this plugin directly. Add the following directive |
54 |
Do not use this plugin directly. Add the following directive |
| 46 |
|
55 |
|
| 47 |
[% PROCESS 'i18n.inc' %] |
56 |
[% PROCESS 'i18n.inc' %] |
|
Lines 183-186
sub tnpx {
Link Here
|
| 183 |
return __npx( $msgctxt, $msgid, $msgid_plural, $count, %$vars ); |
192 |
return __npx( $msgctxt, $msgid, $msgid_plural, $count, %$vars ); |
| 184 |
} |
193 |
} |
| 185 |
|
194 |
|
|
|
195 |
=head2 td |
| 196 |
|
| 197 |
[% I18N.td("TextDomain", "hello") %] |
| 198 |
|
| 199 |
Same as t, but with textdomain as first argument. Useful for plugins |
| 200 |
|
| 201 |
=cut |
| 202 |
|
| 203 |
sub td { |
| 204 |
my ($self, $textdomain, $msgid) = @_; |
| 205 |
return __d($textdomain, $msgid); |
| 206 |
} |
| 207 |
|
| 208 |
=head2 tdn |
| 209 |
|
| 210 |
[% I18N.tdn("TextDomain", "item", "items", count) %] |
| 211 |
|
| 212 |
Same as tn, but with textdomain as first argument. Useful for plugins |
| 213 |
|
| 214 |
=cut |
| 215 |
|
| 216 |
sub tdn { |
| 217 |
my ( $self, $textdomain, $msgid, $msgid_plural, $count ) = @_; |
| 218 |
return __dn( $textdomain, $msgid, $msgid_plural, $count ); |
| 219 |
} |
| 220 |
|
| 221 |
=head2 tdp |
| 222 |
|
| 223 |
[% I18N.tdp("TextDomain", "context", "hello") %] |
| 224 |
|
| 225 |
Same as tp, but with textdomain as first argument. Useful for plugins |
| 226 |
|
| 227 |
=cut |
| 228 |
|
| 229 |
sub tdp { |
| 230 |
my ( $self, $textdomain, $msgctxt, $msgid ) = @_; |
| 231 |
return __p( $textdomain, $msgctxt, $msgid ); |
| 232 |
} |
| 233 |
|
| 234 |
=head2 tdnp |
| 235 |
|
| 236 |
[% I18N.tdnp("TextDomain", "context", "item", "items", count) %] |
| 237 |
|
| 238 |
Same as tnp, but with textdomain as first argument. Useful for plugins |
| 239 |
|
| 240 |
=cut |
| 241 |
|
| 242 |
sub tdnp { |
| 243 |
my ( $self, $textdomain, $msgctxt, $msgid, $msgid_plural, $count ) = @_; |
| 244 |
return __np( $textdomain, $msgctxt, $msgid, $msgid_plural, $count ); |
| 245 |
} |
| 246 |
|
| 247 |
=head2 tdx |
| 248 |
|
| 249 |
[% I18N.tdx("TextDomain", "hello {name}", { name = name }) %] |
| 250 |
|
| 251 |
Same as tx, but with textdomain as first argument. Useful for plugins |
| 252 |
|
| 253 |
=cut |
| 254 |
|
| 255 |
sub tdx { |
| 256 |
my ($self, $textdomain, $msgid, $vars) = @_; |
| 257 |
return __dx($textdomain, $msgid, %$vars); |
| 258 |
} |
| 259 |
|
| 260 |
=head2 tdnx |
| 261 |
|
| 262 |
[% I18N.tdnx("TextDomain", "{count} item", "{count} items", count, { count = count }) %] |
| 263 |
|
| 264 |
Same as tnx, but with textdomain as first argument. Useful for plugins |
| 265 |
|
| 266 |
=cut |
| 267 |
|
| 268 |
sub tdnx { |
| 269 |
my ( $self, $textdomain, $msgid, $msgid_plural, $count, $vars ) = @_; |
| 270 |
return __dnx( $textdomain, $msgid, $msgid_plural, $count, %$vars ); |
| 271 |
} |
| 272 |
|
| 273 |
=head2 tdpx |
| 274 |
|
| 275 |
[% I18N.tdpx("TextDomain", "context", "hello {name}", { name = name }) %] |
| 276 |
|
| 277 |
Same as tpx, but with textdomain as first argument. Useful for plugins |
| 278 |
|
| 279 |
=cut |
| 280 |
|
| 281 |
sub tdpx { |
| 282 |
my ( $self, $textdomain, $msgctxt, $msgid, $vars ) = @_; |
| 283 |
return __p( $textdomain, $msgctxt, $msgid, %$vars ); |
| 284 |
} |
| 285 |
|
| 286 |
=head2 tdnpx |
| 287 |
|
| 288 |
[% I18N.tdnpx("TextDomain", "context", "{count} item", "{count} items", count, { count = count }) %] |
| 289 |
|
| 290 |
Same as tnpx, but with textdomain as first argument. Useful for plugins |
| 291 |
|
| 292 |
=cut |
| 293 |
|
| 294 |
sub tdnpx { |
| 295 |
my ( $self, $textdomain, $msgctxt, $msgid, $msgid_plural, $count, $vars ) = @_; |
| 296 |
return __npx( $textdomain, $msgctxt, $msgid, $msgid_plural, $count, %$vars ); |
| 297 |
} |
| 298 |
|
| 186 |
1; |
299 |
1; |