Line 0
Link Here
|
0 |
- |
1 |
package Koha::Template::Plugin::Languages; |
|
|
2 |
|
3 |
# Copyright 2012 ByWater Solutions |
4 |
# Copyright 2013-2014 BibLibre |
5 |
# |
6 |
# Koha is free software; you can redistribute it and/or modify it |
7 |
# under the terms of the GNU General Public License as published by |
8 |
# the Free Software Foundation; either version 3 of the License, or |
9 |
# (at your option) any later version. |
10 |
# |
11 |
# Koha is distributed in the hope that it will be useful, but |
12 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
# GNU General Public License for more details. |
15 |
# |
16 |
# You should have received a copy of the GNU General Public License |
17 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
18 |
|
19 |
use Modern::Perl; |
20 |
|
21 |
use Template::Plugin; |
22 |
use base qw( Template::Plugin ); |
23 |
|
24 |
use C4::Koha; |
25 |
use C4::Languages; |
26 |
|
27 |
sub GetByISOCode { |
28 |
my ( $self, $lang, $code ) = @_; |
29 |
$lang = substr($lang,0,2); #Get db code from Koha lang value |
30 |
my $rfc = C4::Languages::get_rfc4646_from_iso639( $code ); |
31 |
my $description = C4::Languages::language_get_description($rfc,$lang,'language'); |
32 |
return $description; |
33 |
} |
34 |
|
35 |
1; |
36 |
|
37 |
=head1 NAME |
38 |
|
39 |
Koha::Template::Plugin::Languages - TT Plugin for languages |
40 |
|
41 |
=head1 SYNOPSIS |
42 |
|
43 |
[% USE Languages %] |
44 |
|
45 |
[% Languages.GetByISOCode( 'LANG', 'ISO639CODE' ) %] |
46 |
|
47 |
=head1 ROUTINES |
48 |
|
49 |
=head2 GetByISOCode |
50 |
|
51 |
In a template, you can get the description for an language value with |
52 |
the following TT code: [% Languages.GetByISOCode( 'LANGUAGE', 'ISO639CODE' ) %] |
53 |
|
54 |
|
55 |
=head1 AUTHOR |
56 |
|
57 |
Nick Clemens <nick@bywatersolutions.com> |
58 |
|
59 |
=cut |