Bug 8044: new module for translating strings in Perl source files
[koha.git] / Koha / I18N.pm
1 package Koha::I18N;
2
3 use base qw(Locale::Maketext);
4
5 use C4::Templates;
6 use C4::Context;
7
8 use Locale::Maketext::Lexicon {
9     'en' => ['Auto'],
10     '*' => [
11         Gettext =>
12             C4::Context->config('intranetdir')
13             . '/misc/translator/po/*-messages.po'
14     ],
15     '_AUTO' => 1,
16 };
17
18 sub get_handle_from_context {
19     my ($class, $cgi, $interface) = @_;
20
21     my $lh;
22     my $lang = C4::Templates::getlanguage($cgi, $interface);
23     if ($lang) {
24         $lh = $class->get_handle($lang)
25             or die "No language handle for '$lang'";
26     } else {
27         $lh = $class->get_handle()
28             or die "Can't get a language handle";
29     }
30
31     return $lh;
32 }
33
34 1;