View | Details | Raw Unified | Return to bug 18213
Collapse All | Expand All

(-)a/C4/Languages.pm (-2 / +6 lines)
Lines 631-638 sub getlanguage { Link Here
631
sub get_rfc4646_from_iso639 {
631
sub get_rfc4646_from_iso639 {
632
632
633
    my $iso_code = shift;
633
    my $iso_code = shift;
634
    my $rfc_subtag = Koha::Database->new()->schema->resultset('LanguageRfc4646ToIso639')->find({iso639_2_code=>$iso_code})->rfc4646_subtag;
634
    my $rfc_subtag = Koha::Database->new()->schema->resultset('LanguageRfc4646ToIso639')->find({iso639_2_code=>$iso_code});
635
    return $rfc_subtag;
635
    if ( $rfc_subtag ) {
636
        return $rfc_subtag->rfc4646_subtag;
637
    } else {
638
        return;
639
    }
636
640
637
}
641
}
638
642
(-)a/Koha/Template/Plugin/Languages.pm (-1 / +59 lines)
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

Return to bug 18213