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

(-)a/Koha/I18N.pm (+29 lines)
Line 0 Link Here
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
    '*' => [Gettext => C4::Context->config('intranetdir') . '/locale/*/messages.po'],
10
    '_AUTO' => 1,
11
};
12
13
sub get_handle_from_context {
14
    my ($class, $cgi, $interface) = @_;
15
16
    my $lh;
17
    my $lang = C4::Templates::getlanguage($cgi, $interface);
18
    if ($lang) {
19
        $lh = $class->get_handle($lang)
20
            or die "No language handle for '$lang'";
21
    } else {
22
        $lh = $class->get_handle()
23
            or die "Can't get a language handle";
24
    }
25
26
    return $lh;
27
}
28
29
1;
(-)a/locale/en/messages.po (+62 lines)
Line 0 Link Here
1
# SOME DESCRIPTIVE TITLE.
2
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
# This file is distributed under the same license as the PACKAGE package.
4
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
#
6
#, fuzzy
7
msgid ""
8
msgstr ""
9
"Project-Id-Version: Koha\n"
10
"Report-Msgid-Bugs-To: \n"
11
"POT-Creation-Date: 2012-05-04 14:23+0200\n"
12
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
"Last-Translator: \n"
14
"Language-Team: English <koha-translate@lists.koha-community.org>\n"
15
"Language: en\n"
16
"MIME-Version: 1.0\n"
17
"Content-Type: text/plain; charset=UTF-8\n"
18
"Content-Transfer-Encoding: 8bit\n"
19
20
#: C4/Acquisition.pm:241
21
msgid "Contract name"
22
msgstr ""
23
24
#: C4/Acquisition.pm:242
25
msgid "Order number"
26
msgstr ""
27
28
#: C4/Acquisition.pm:243
29
msgid "Entry date"
30
msgstr ""
31
32
#: C4/Acquisition.pm:244
33
msgid "ISBN"
34
msgstr ""
35
36
#: C4/Acquisition.pm:245
37
msgid "Author"
38
msgstr ""
39
40
#: C4/Acquisition.pm:246
41
msgid "Title"
42
msgstr ""
43
44
#: C4/Acquisition.pm:247
45
msgid "Publisher code"
46
msgstr ""
47
48
#: C4/Acquisition.pm:248
49
msgid "Collection title"
50
msgstr ""
51
52
#: C4/Acquisition.pm:249
53
msgid "Notes"
54
msgstr ""
55
56
#: C4/Acquisition.pm:250
57
msgid "Quantity"
58
msgstr ""
59
60
#: C4/Acquisition.pm:251
61
msgid "RRP"
62
msgstr ""
(-)a/locale/update_po.pl (-1 / +61 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
use Modern::Perl;
4
use Data::Dumper;
5
use FindBin qw($Bin);
6
7
my $localedir = $Bin;
8
my $installdir = "$localedir/..";
9
10
# Directories are not scanned recursively
11
my @directories_to_scan = qw(
12
    . C4 acqui admin authorities basket catalogue cataloguing circ errors
13
    Koha labels members misc offline_circ opac patroncards reports
14
    reserve reviews rotating_collections serials services sms suggestion tags
15
    tools virtualshelves
16
);
17
18
# Build files list
19
my @files_to_scan;
20
foreach my $dir (@directories_to_scan) {
21
    opendir DIR, "$installdir/$dir" or die "Unable to open $dir: $!";
22
    while (readdir DIR) {
23
        next unless ( -f "$installdir/$dir/$_" );
24
        next unless ( $_ =~ /(\.pl|\.pm)$/ );
25
        push @files_to_scan, "$dir/$_";
26
    }
27
    closedir DIR;
28
}
29
30
# Build languages list
31
my @langs;
32
opendir DIR, $localedir;
33
while (readdir DIR) {
34
    next unless ( -d "$localedir/$_" );
35
    next if ($_ eq '.' or $_ eq '..');
36
    push @langs, $_;
37
}
38
close DIR;
39
40
my $xgettext = `which xgettext`;
41
chomp $xgettext;
42
my $xgettext_cmd = "$xgettext -L Perl --from-code=UTF-8 -kmaketext -o messages.pot";
43
$xgettext_cmd .= " -D $installdir/$_" foreach (@directories_to_scan);
44
$xgettext_cmd .= " $_" foreach (@files_to_scan);
45
46
say "Extracting strings from source...";
47
if (system($xgettext_cmd) != 0) {
48
    die "system call failed : $xgettext_cmd";
49
}
50
51
foreach my $lang (@langs) {
52
    if ( -f "$localedir/$lang/messages.po" ) {
53
        say "Updating $lang...";
54
        system("msgmerge -U $localedir/$lang/messages.po messages.pot");
55
    } else {
56
        say "No PO file for $lang. Creating one...";
57
        system("cp messages.pot $localedir/$lang/messages.po");
58
    }
59
}
60
61
unlink "messages.pot";

Return to bug 8044